2017-02-09 57 views
0

如何在打開應用程序時獲取推送通知。僅當應用程序關閉或在後臺時才獲取推送通知。在應用程序在目標c中打開時獲取PushNotification

+0

,如果你想在其他iOS版本可用比你創建自己的notificationview檢查這個http://stackoverflow.com/questions/14872088/get-push-notification-while-app -in-foreground-ios – iOS

回答

0

當應用程序是背景或前景時應用沒有存儲器

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler 

將被調用,需要在其上打開的應用程序,並需要處理它

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
推送通知的用戶交互
0

您的問題並不十分清楚,但是如果您要在通知窗口中顯示通知,即使您的應用程序處於活動狀態,您也需要處理相同的問題

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)pushMessage 

併發布具有相同有效負載的新本地通知。然後你就可以處理在

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif 
0

一般來說,如果應用程序在前臺運行,iOS的不 顯示通知橫幅/ alert.That的由design.When應用程序是在forground,如果你想顯示推送通知,您可以使用iOS 10的UserNotification Framework,並將通知顯示或顯示爲banner.also您可以使用UILocalNotification來實現此目的。主要我們使用didReceiveRemoteNotification方法來實現此目的。現在我們擁有iOS 10的UIUserNotification方法。

When application is foreground and background state getting push notification

Showing Push Notification in foreground state iOS 10

在IOS 0 thisfeature
+0

而不是鏈接到堆棧溢出中的其他帖子的答案,投票結束這個問題的重複。 – JAL

相關問題