### ### ### ### ### ### ## NSFoundationVersionNumber_iOS_9_x_Max #import
#endif // Optional header files to import if you want to use idFA functionality #import
# # # and then registered JPush – (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
If (launchOptions) {// Get push notification definition userinfo NSDictionary * remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (remoteNotification) { roomid = remoteNotification[@”roomId”]; nickName = remoteNotification[@”senderNickName”]; [self setupMainViewController]; }else{ [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; } //notice: JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init]; notice: JPUSHRegisterEntity * entity = [JPUSHRegisterEntity alloc] init]; entity.types=JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound; If ([[UIDevice currentDevice].SystemVersion floatValue] >= 8.0) {// You can add custom categories // NSSet
*categories for iOS10 or later // NSSet
*categories for iOS8 and iOS9 } [JPUSHService registerForRemoteNotificationConfig:entity delegate:self]; // Optional // Obtain IDFA. // To use the IDFA function, add this code and enter the value NSString *advertisingId = in the advertisingIdentifier parameter of the initialization method [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; // Required // init Push // notice: 2.1.5 SDK added a new registration method, change to report IDFA, if you do not use IDFA directly pass nil // If you need to continue to use pushconfig. plist file declaration appKey configuration content, etc. Please still use [JPUSHService setupWithOption: launchOptions] way to initialize. [JPUSHService setupWithOption:launchOptions appKey:@”appKey” channel:@”AppStore” apsForProduction:0 advertisingIdentifier:advertisingId]; return YES; }
# # # pragma mark – iOS10 notified (local and remote) UNUserNotificationCenterDelegate / / App in front desk receive notifications Are the app in a state of the front desk State of the front desk and front desk will go under, – (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *) notification withCompletionHandler: (void) (^) (UNNotificationPresentationOptions) completionHandler {/ / received a request push UNNotificationRequest *request = notification.request; UNNotificationContent *content = request.content; UNNotificationContent *content = request.content; NSDictionary *userInfo = content.userinfo; NSNumber *badge = content.badge; NSString *body = content.body; UNNotificationSound *sound = content.sound; NSString *subtitle = content.subtitle; NSString *subtitle = content.subtitle; NSString *title = content.title; If ([notification request. The trigger isKindOfClass: [UNPushNotificationTrigger class]]) {/ / is omitted ten thousand lines demand code… // NSLog(@”iOS10 received remote notification :%@”,userInfo); }else {// Determine local notification // omit ten thousand lines of required code…… Local NSLog (@ “iOS10 advised: {\ \ \ \ nbody: % @, \ \ \ \ ntitle: % @, \ \ \ \ nsubtitle: % @, \ \ \ \ nbadge: % @, \ \ \ \ nsound: % @, \ \ \ \ nuserInfo: %@\\\\n}”,body,title,subtitle,badge,sound,userInfo); }
// To execute this method, select whether to remind the user, Have a Badge, Sound, Alert three types can set the completionHandler (UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound| UNNotificationPresentationOptionAlert); }
The proxy method below the click event of the ####App notification, – (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{ / / received a request push UNNotificationRequest * request = response. The notification, request; UNNotificationContent *content = request.content; UNNotificationContent *content = request.content; NSDictionary *userInfo = content.userinfo; NSNumber *badge = content.badge; NSString *body = content.body; UNNotificationSound *sound = content.sound; NSString *subtitle = content.subtitle; NSString *subtitle = content.subtitle; NSString *title = content.title; if([response.notification.request.trigger isKindOfClass: [UNPushNotificationTrigger class]]) {NSLog (@ “iOS10 receive remote notifications: % @”, the userInfo); // Omit 10,000 lines of required code here… }else {// Determine local notification // omit ten thousand lines of required code…… Local NSLog (@ “iOS10 advised: {\ \ \ \ nbody: % @, \ \ \ \ ntitle: % @, \ \ \ \ nsubtitle: % @, \ \ \ \ nbadge: % @, \ \ \ \ nsound: % @, \ \ \ \ nuserInfo: %@\\\\n}”,body,title,subtitle,badge,sound,userInfo); } completionHandler(); // The system requires this method to be executed}
####pragma mark -iOS 10 received notification before – (void)application:(UIApplication *)application DidReceiveRemoteNotification: (NSDictionary *) the userInfo {NSLog (@ “iOS6 and the following system, notified: % @”, the userInfo); [JPUSHService handleRemoteNotification:userInfo]; // Omit 10,000 lines of required code here… }
– (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo FetchCompletionHandler :(void (^)(UIBackgroundFetchResult))completionHandler {NSLog(@”iOS7 and above, received notification :%@”, userInfo); [JPUSHService handleRemoteNotification:userInfo]; completionHandler(UIBackgroundFetchResultNewData); // Omit 10,000 lines of required code here… }
######appKey specifies the download channel of the application package in aurora ######channel. For the convenience of statistics by channel, the specific value is customized by you. ######apsForProduction 0 (default value) indicates that the development certificate is used. 1: use the production certificate for publishing ######advertisingIdentifier
DeviceToken – (void)application:(UIApplication *)application DeviceToken didRegisterForRemoteNotificationsWithDeviceToken: (NSData *) {/ / Required – registered deviceToken [JPUSHService registerDeviceToken:deviceToken]; / / should be here will get registrationID and server storage user binding to implement fixed-point push [JPUSHService registrationIDCompletionHandler: ^ (int resCode, NSString *registrationID) { NSLog(@”%@”, registrationID); }]; }
– (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { //Optional NSLog(@”did Fail To Register For Remote Notifications With Error: %@”, error); } ### add pragma mark- JPUSHRegisterDelegate // iOS 10 Support – (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler { // Required NSDictionary * userInfo = notification.request.content.userInfo; if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { [JPUSHService handleRemoteNotification:userInfo]; } completionHandler(UNNotificationPresentationOptionAlert); // If you want to pass this on to the user, you can pass it on to the user by Badge, Sound or Alert.
// iOS 10 Support – (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { // Required NSDictionary * userInfo = response.notification.request.content.userInfo; if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { [JPUSHService handleRemoteNotification:userInfo]; } completionHandler(); // The system requires this method to be executed}
Before the # pragma mark – iOS 10 notified – (void) application: (UIApplication *) application didReceiveRemoteNotification: (NSDictionary *)userInfo {NSLog(@”iOS6 and below, receive notification :%@”, userInfo); [JPUSHService handleRemoteNotification:userInfo]; // Omit 10,000 lines of required code here… }
# # # registered
### run successfully
##### Real machine debugging of the project, if the console output the following log represents that you have successfully integrated.
2016-08-19 17:12:12. 745823 219 b28 [1443-286814] | JPUSH | I – [JPUSHLogin] — — — — — login result — — — — — uid: 5460310207 registrationID:171976fa8a8620a14a4
## Configure the certificate
Create the App ID and fill in the NAME and Bundle ID of the App ID (skip this step if the ID already exists).
Enable Push Notification for App. If the App ID is already created, you can enable the Push Notification function.
If you have not created a Push certificate before or want to create a new one, create one under the certificate list.
When creating a certificate, select the APNs certificate type. Figure APNs certificates have two types: Development and Production.
Note: Development certificate is used for development and debugging; Production certificates can be used for both development and commissioning as well as product release. Here we choose the production certificate as an example.
Click “Continue” and select the AppID to bind to for the certificate.
Click “Continue” to enter the CSR description screen. Clicking “Continue” will cause you to upload the CSR file. (THE CSR file will be created in the next step)
Open KeychainAccess to create the Certificate Signing Request. Operation as shown below:
Set Email and Common Name, select Store to Disk, and set the certificate file extension to.certSigningRequest.
Go back to the CSR upload page in your browser and upload the file you just generated with the suffix.certSigningRequest. After the certificate is generated, click “Download” to Download the certificate. Cer file.
Double-click the certificate to open it in KeychainAccess. Select Login in the left keychain list and My Certificate in the Type list to find the downloaded certificate and export it as a.p12 file. The diagram below:
On the Aurora console, go to your app’s App Settings iOS authentication mode and select Certificate and upload the.p12 certificate you just exported. Aurora will authenticate your application in the background.
##### Development Environment testing Before testing the JPush iOS development environment, make sure there are three things in common: Before testing the JPush iOS production environment, please make sure that there are three things in common: App is ad-hoc packaging or App Store version (publishing certificate Production) upload the publishing certificate and verify other problems that may exist through #### Receiving messages is not stable enough. JPush iOS is a supplement to the original official APNs push. Is a wrapper around it to make it easier for developers to use APNs. Since APNs itself does not promise to ensure message arrival, the connectivity between the client network and the server has a great impact on whether APNs receives messages in time.