【发布时间】:2016-03-12 07:46:11
【问题描述】:
我已将我的应用设置为使用 GCM。
我已成功添加代码以将 GCM 集成到我的应用中。
现在我有两种方法来处理推送通知:
- 默认方法
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"Notification received: %@", userInfo);
// This works only if the app started the GCM service
[[GCMService sharedInstance] appDidReceiveMessage:userInfo];
}
-
GCM 方法
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler { NSLog(@"Notification received: %@", userInfo); // This works only if the app started the GCM service [[GCMService sharedInstance] appDidReceiveMessage:userInfo]; // Handle the received message // Invoke the completion handler passing the appropriate UIBackgroundFetchResult value // ... }
现在我很困惑我应该在哪里处理我的Notificaiton。
我应该在哪里检查application状态并调用我的方法来处理它。
我应该在这两种方法中都写方法吗?
【问题讨论】:
标签: ios objective-c push-notification google-cloud-messaging apple-push-notifications