The Aurora push for iOS learning

Source: Internet
Author: User

One, Aurora push engineering end

1. Download the SDK

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

Integrated Package Contents: Package name jpush-ios-sdk-{version number}

    • Lib folder: Contains header file JPUSHService.h, static library file jpush-ios-x.x.x.a, supported iOS version 5.0 and later. (Note: Emulator does not support APNs)

    • PDF file: Integration Guide

    • Demo folder: Example

As the above introduction, we need Lib folder in the project , so we just need to import the Lib folder .

2, import the necessary framework

    • Cfnetwork.framework

    • Corefoundation.framework

    • Coretelephony.framework

    • Systemconfiguration.framework

    • Coregraphics.framework

    • Foundation.framework

    • Uikit.framework

    • Security.framework

    • Xcode7 need is libz.tbd; Xcode7 The following versions are Libz.dylib

    • Adsupport.framework (get IDFA required; Do not add if IDFA is not used)

3. plist File Creation Pit

There is a pit in the Aurora help document that creates and configures the Pushconfig.plist file. If you initialize JPUSHService using Aurora <= 1.8.8版本的SDK的注册方法(+ (void)setupWithOption:(NSDictionary *)launchingOption; 以弃用)就创建, , you do not need to use a later version of the initialization method. I'm using the latest version now 2.1.5 , so I didn't create a pushconfig.plist file .

4. Code

Now import the following two header files into the Appdelegate

// Aurora Service Header file #import " JPUSHService.h " // Asidentifiermanager Controller header files, ads, can not be used #import <AdSupport/ASIdentifierManager.h>

Calling code

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after application launch. //Advertising (not normally used)//nsstring *advertisingid = [[[Asidentifiermanager Sharedmanager] advertisingidentifier] UUIDString]; //Required    if([[Uidevice currentdevice].systemversion Floatvalue] >=8.0) {        //You can add a custom categories[Jpushservice registerforremotenotificationtypes: (Uiusernotificationtypebadge |Uiusernotificationtypesound|Uiusernotificationtypealert)    Categories:nil]; } Else {        //the categories must be nil .[Jpushservice registerforremotenotificationtypes: (Uiremotenotificationtypebadge |Uiremotenotificationtypesound|Uiremotenotificationtypealert)    Categories:nil]; }    //Required//If you need to continue to use the Pushconfig.plist file to declare configuration content such as Appkey, still use [Jpushservice setupwithoption:launchoptions] to initialize. [Jpushservice setupwithoption:launchoptions AppKey:@ "The Appkey of the app you created" // attention must be given to your own  Channel:@"App Store" //Specify the download channel for the application package, which you define for the convenience of the channel statisticsApsforproduction:0 //1.3.1 new, used to identify the current application using the APNS Certificate environment 0 (the default) means that the development certificate is adopted, 1 means that the application is published with a production certificateAdvertisingidentifier:nil];//set Advertisingidentifier to nil if not used//Advertisingidentifier:advertisingid]; //You can also use this initialization method when you create a plist file in the pit//[Jpushservice setupwithoption:launchoptions];        returnYES;}#pragmaMark-Monitor-(void) Application: (UIApplication *) Applicationdidregisterforremotenotificationswithdevicetoken: (NSData*) Devicetoken {///Required-Register DevicetokenNSLog (@"%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 {//OptionalNSLog (@"Did Fail to Register for Remote notifications with Error:%@", error);}

5, about advertising (IDFA)

r2.1.5 version adds an interface to upload IDFA strings:

+ (void) Setupwithoption: (Nsdictionary *) launchingoption                  *) appKey                 *) Channel        apsforproduction: (BOOL) isproduction   

This method is what I used above, if you do not use IDFA, you can still use the following interface:

+ (void) Setupwithoption: (Nsdictionary *) launchingoption                  *) appKey                 *) Channel        apsforproduction: (BOOL) isproduction;

Summary: Three types of initialization methods can be chosen according to your own needs.

6. Allow XCode7 to support HTTP transmission method

If you are using XCODE7, you need to manually configure the key and value in the plist of the app project to support HTTP transport:

Option 1: According to the domain name configuration

    • Add a Key:app Transport Security Settings in the info.plist of the project, which is of type dictionary type.

    • A key:allow arbitrary Loads is added to the dictionary, 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 your project in all the configuration, the following is about the Aurora push server-side operation!

Second, Aurora push server Side

1. Registered users

2. Create an App

3. Send Notifications

The notification content can be filled in directly

The push object needs to be selected, such as:

Registrationid will print on your project's console, and you can send a notification to a person based on this.

Above is I to the Aurora push a small summary and finishing, we have better words, on the link!!!!

The Aurora push for iOS learning

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.