簡體   English   中英

iOS-無法在終止的應用程序中接收JSON推送通知

[英]ios - can not receive json push notification in terminated app

我正在iOS中進行推送通知。

我使用parse.com服務進行推送通知。

當我發送文本通知時,一切都很好。

但是當我通過雙擊主頁按鈕終止應用程序並滑動應用程序時,則不會收到json通知。 (換句話說,未調用方法“應用程序:didReceiveRemoteNotification:”)。

我使用NSLog代碼檢查通知接收和監視設備控制台。

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo{
      NSLog(@"Receive notification in didReceiveRemoteNotification %@", userInfo);
}

我在stackoverflow帖子中閱讀了所有類似的問題,但未找到答案。

編輯1:

我啟用了后台模式->遠程通知

當您的應用程序處於后台時,會收到遠程通知,但是“ application:didReceiveRemoteNotification:”未稱為對嗎?

並啟用后台模式

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                UIUserNotificationTypeBadge |
                                                UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                         categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
  // Extract the notification data
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM