ios - 程序在后台运行时收到通知didReceiveRemoteNotification不执行
ringa_lee
ringa_lee 2017-04-17 17:39:56
0
3
622

我的app在后台运行时,收到远程推送,通知栏已经有提醒了,这时候如果我点击app 的icon 运行程序,didReceiveRemoteNotification方法并不执行。请问这个怎么解决?
如果我是点击通知栏上的推送,didReceiveRemoteNotification是执行的。

ringa_lee
ringa_lee

ringa_lee

reply all(3)
小葫芦

Try the project configuration
Capabilities BackgroundModes -> ON select RemoteNotification

黄舟

This is a normal situation. This function is originally triggered after clicking on the notification

伊谢尔伦

If your application is started, click the application icon to start, it will be in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions NS_AVAILABLE_IOS(3_0);
The Key value in

is as follows

    NSDictionary *pushInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

You can get the notification content,
If the application is in the background, clicking the application icon will not call other proxy methods for notifications unless you click the banner. There is nothing unreasonable in this, and it is the same for many applications. For processing, the
application is in the foreground and will only follow the method you mentioned after receiving the push. In addition, if you implement

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;

Then it will be called in this method, and the method you mentioned will be abolished.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template