@@ -38,13 +38,26 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3838 return YES ;
3939}
4040
41+ // Required to register for notifications
42+ - (void )application : (UIApplication *)application didRegisterUserNotificationSettings : (UIUserNotificationSettings *)notificationSettings
43+ {
44+ [XGPushManager didRegisterUserNotificationSettings: notificationSettings];
45+ }
46+
4147- (void )application : (UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken {
42- NSLog ( @" [XGDemo] device token is %@ " , [[XGPushTokenManager defaultTokenManager ] deviceTokenString ]) ;
48+ [XGPushManager didRegisterForRemoteNotificationsWithDeviceToken: deviceToken] ;
4349}
4450
51+ // Required for the registrationError event.
4552- (void )application : (UIApplication *)application didFailToRegisterForRemoteNotificationsWithError : (NSError *)error {
46- NSLog (@" [XGDemo] register APNS fail.\n [XGDemo] reason : %@ " , error);
47- [[NSNotificationCenter defaultCenter ] postNotificationName: @" registerDeviceFailed" object: nil ];
53+ NSLog (@" [XGPush] register APNS fail.\n [XGPush] reason : %@ " , error);
54+ [XGPushManager didFailToRegisterForRemoteNotificationsWithError: error];
55+ }
56+
57+ // Required for the localNotification event.
58+ - (void )application : (UIApplication *)application didReceiveLocalNotification : (UILocalNotification *)notification
59+ {
60+ [XGPushManager didReceiveLocalNotification: notification];
4861}
4962
5063/* *
@@ -55,8 +68,8 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif
5568 @param completionHandler 完成回调
5669 */
5770- (void )application : (UIApplication *)application didReceiveRemoteNotification : (NSDictionary *)userInfo fetchCompletionHandler : (void (^)(UIBackgroundFetchResult))completionHandler {
58- NSLog (@" [XGDemo ] receive slient Notification" );
59- NSLog (@" [XGDemo ] userinfo %@ " , userInfo);
71+ NSLog (@" [XGPush ] receive slient Notification" );
72+ NSLog (@" [XGPush ] userinfo %@ " , userInfo);
6073 UIApplicationState state = [application applicationState ];
6174 BOOL isClicked = (state != UIApplicationStateActive);
6275 NSMutableDictionary *remoteNotification = [NSMutableDictionary dictionaryWithDictionary: userInfo];
@@ -65,7 +78,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
6578 remoteNotification[@" background" ] = @YES ;
6679 }
6780 [[XGPush defaultManager ] reportXGNotificationInfo: remoteNotification];
68- completionHandler (UIBackgroundFetchResultNewData) ;
81+ [XGPushManager didReceiveRemoteNotification: userInfo fetchCompletionHandler: completionHandler] ;
6982}
7083
7184// iOS 10 新增 API
@@ -76,7 +89,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
7689// App 用户在通知中心清除消息
7790// 无论本地推送还是远程推送都会走这个回调
7891- (void )xgPushUserNotificationCenter : (UNUserNotificationCenter *)center didReceiveNotificationResponse : (UNNotificationResponse *)response withCompletionHandler : (void (^)(void ))completionHandler {
79- NSLog (@" [XGDemo ] click notification" );
92+ NSLog (@" [XGPush ] click notification" );
8093 if ([response.actionIdentifier isEqualToString: @" xgaction001" ]) {
8194 NSLog (@" click from Action1" );
8295 } else if ([response.actionIdentifier isEqualToString: @" xgaction002" ]) {
0 commit comments