Aurora push for iOS learning and Aurora push for ios

Source: Internet
Author: User
Tags to domain

Aurora push for iOS learning and Aurora push for ios
I. Aurora push project end

1. Download the SDK

Aurora push is a third-party push message, SDK download: https://www.jpush.cn/common/products

Integrated compressed Package content: package name: JPush-iOS-SDK-{version number}

  • Lib Folder: contains header file JPUSHService. h, static library file jpush-ios-x.x.x.a, supports iOS version 5.0 and later. (Note: The simulator does not support APNs)

  • PDF file: Integration Guide

  • Demo Folder: Example

As described above, we need the lib folder in the project, so we only need to import the lib folder.

2. Import necessary frameworks

  • CFNetwork. framework

  • CoreFoundation. framework

  • CoreTelephony. framework

  • SystemConfiguration. framework

  • CoreGraphics. framework

  • Foundation. framework

  • UIKit. framework

  • Security. framework

  • Libz. tbd is required for Xcode7; libz. dylib is required for versions earlier than Xcode7.

  • Adsupport. framework (required to obtain IDFA; do not add IDFA if IDFA is not used)

3. plist File Creation

There is a pitfall in the Aurora help document, that is, creating and configuring the PushConfig. plist file. If InitializationJPUSHServiceUse Aurora<= 1.8.8 SDK registration method (+ (void)setupWithOption:(NSDictionary *)launchingOption;Discard,If you use the initialization method of a later version, you do not need. I will use the latest version below2.1.5So no PushConfig. plist file is created.

4. Code

Now, import the following two header files to AppDelegate:

// Aurora service header file
#import "JPUSHService.h"
// ASIdentifierManager controller header file, advertisement, can not be used
#import <AdSupport / ASIdentifierManager.h>
Call code

-(BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {
    // Override point for customization after application launch.
    
    // Advertising (generally not used)
// NSString * advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    // Required
    if ([[UIDevice currentDevice] .systemVersion floatValue]> = 8.0) {
        // Can add custom categories
        [JPUSHService registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge |
                                                          UIUserNotificationTypeSound |
                                                          UIUserNotificationTypeAlert)
                                              categories: nil];
    } else {
        // categories must be nil
        [JPUSHService registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge |
                                                          UIRemoteNotificationTypeSound |
                                                          UIRemoteNotificationTypeAlert)
                                              categories: nil];
    }
    // Required
    // If you want to continue to use pushConfig.plist file to declare appKey and other configuration content, please still use [JPUSHService setupWithOption: launchOptions] to initialize.
    [JPUSHService setupWithOption: launchOptions appKey: @ "APPKey of the app you created" // Note that it must be your own
                          channel: @ "App Store" // Specify the download channel of the application package. For the convenience of sub-channel statistics, the specific value is defined by you
                 apsForProduction: 0 // New in version 1.3.1, used to identify the APNs certificate environment used by the current application 0 (default) indicates that a development certificate is used, and 1 indicates that a production certificate is used to release the application
            advertisingIdentifier: nil]; // Set advertisingIdentifier to nil if not used
// advertisingIdentifier: advertisingId];
    
    // When you create a plist file into the pit, you can also use this initialization method
// [JPUSHService setupWithOption: launchOptions];
    
    return YES;
}

#pragma mark-monitor
-(void) application: (UIApplication *) application
didRegisterForRemoteNotificationsWithDeviceToken: (NSData *) deviceToken {
    
    /// Required-Register DeviceToken
    NSLog (@ "% d == deviceToken ==% @", __ LINE__, deviceToken);
    [JPUSHService registerDeviceToken: deviceToken];
}

// Feedback to the server
-(void) application: (UIApplication *) application didReceiveRemoteNotification: (NSDictionary *) userInfo {
    
    // Required, For systems with less than or equal to iOS6
    
    [UIApplication sharedApplication] .applicationIconBadgeNumber = 0;
    
    [JPUSHService handleRemoteNotification: userInfo];
}

-(void) application: (UIApplication *) application didFailToRegisterForRemoteNotificationsWithError: (NSError *) error {
    // Optional
    NSLog (@ "did Fail To Register For Remote Notifications With Error:% @", error);
}
5. About Advertising (IDFA)

R2.1.5 version adds an interface to upload IDFA string:

+ (void) setupWithOption: (NSDictionary *) launchingOption
                  appKey: (NSString *) appKey
                 channel: (NSString *) channel
        apsForProduction: (BOOL) isProduction
   advertisingIdentifier: (NSString *) advertisingId;
This method is what I used above. If you do n’t use IDFA, you can still use the following interface:

+ (void) setupWithOption: (NSDictionary *) launchingOption
                  appKey: (NSString *) appKey
                 channel: (NSString *) channel
        apsForProduction: (BOOL) isProduction;
Summary: The three initialization methods can be chosen according to your own needs.

6. Allow XCode7 to support Http transmission method

If you use Xcode7, you need to manually configure the key and value in the plist of the App project to support http transmission:

Option 1: Configure according to domain name

Add a Key in the project's info.plist: App Transport Security Settings, the type is a dictionary type.

Add a Key to the dictionary: Allow Arbitrary Loads, the type is Boolean, and the value is YES.



Option 2: Global configuration

<key> NSAppTransportSecurity </ key>
<dict>
    <key> NSAllowsArbitraryLoads </ key>
<True />
</ dict>
The above is all your configuration in the project, the following is about the operation of the Aurora push server!

2. Aurora Push Server

1. Registered users

2. Create an application

3. Send notification

Notify the content directly

Push objects need to be selected on the line, such as:

RegistrationID will be printed on the console of your project, you can send a notification to a person based on this

The above is a small summary and finishing of the Aurora push, if you have better, just link! ! ! !

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.