(void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo ;
和
- (void)application:(UIApplication *)application didReceiveRemoteNotification:
(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult
result))completionHandler{};
永远不会被叫,虽然我收到了iPhone上的通知,是否还需要添加其他功能才能使用?谢谢 .
Update 当应用程序不在后台或活动但我没有收到消息时我尝试了这个 . - (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//设置应用程序的客户端ID | GPPSignIn |和| GPPShare | .
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
// Clear application badge when app launches
application.applicationIconBadgeNumber = 0;
if ([[launchOptions allKeys] containsObject:UIApplicationLaunchOptionsRemoteNotificationKey]) {
id userInfo=[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"MESSAGE" message:userInfo delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alert show];
}
1 回答
如果您的申请关闭并获得通知.....
在
didFinishLaunchingWithOptions
中添加以下代码但是当你点击通知时这个电话