使用FCM的推送通知iOS中10:火力地堡背景和非活動的通知不顯示的iOS
這是天色通過我們自己的API推送通知後稱爲剪斷:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification
[[FIRMessaging messaging] appDidReceiveMessage:userInfo];
if (userInfo[kGCMMessageIDKey]) {
NSLog(@"Message ID: %@", userInfo[kGCMMessageIDKey]);
}
completionHandler(UIBackgroundFetchResultNewData);
if(application.applicationState == UIApplicationStateBackground){
[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Bacgkround"
description:@"Wassup"
type:TWMessageBarMessageTypeSuccess callback:^{
}];
}
else if(application.applicationState == UIApplicationStateActive){
[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Active"
description:@"Wassup"
type:TWMessageBarMessageTypeSuccess callback:^{
}];
}
else if(application.applicationState == UIApplicationStateInactive){
[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"InActive"
description:@"Wassup"
type:TWMessageBarMessageTypeSuccess callback:^{
}];
}
}
當應用程序是活動的,上面的方法被調用和UIApplicationStateActive情況下得到執行,我顯示一個彈出使用第三方庫。當我按主頁按鈕並推送通知時,上面的方法被調用並且UIApplicationStateBackground被執行,但我不知道如何以橫幅形式顯示通知?
這是我必須處理通知的方法是什麼?如果是,我該如何處理Background和Inactive狀態?
但我需要寫在UIApplicationStateBackground情況下,正確的東西嗎? –
我不這麼認爲,我從來沒有做過任何處理推送通知'UIApplicationStateBackground',iOS將自行 –
處理它在這種情況下, - (空)userNotificationCenter:(UNUserNotificationCenter *)中心 didReceiveNotificationResponse:(UNNotificationResponse *)響應 withCompletionHandler:(void(^)())completionHandler {}方法在我的情況下沒有被調用! –