通过单击应用程序图标直接启动应用程序时,无法推送通知数据 [英] Push notification data not getting when app launched directly by clicking app icon

查看:100
本文介绍了通过单击应用程序图标直接启动应用程序时,无法推送通知数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序将获得推送通知并需要在我的应用程序的主屏幕中显示该消息的情况,因为我将消息数组保存到我的应用程序委托的用户默认值,一切正常,但在以下条件它不起作用

I have a scenario in which app will get push notification and need to show that messages in home screen of my app, for that i saved the message array into user defaults from my app delegate and everything works well, but in following conditions it's not working


  1. 如果应用程序处于被杀死状态并且有通知,用户通过应用程序图标触发应用程序(不是来自推送通知)

  1. if app is in killed state and a notification came and user triggeres the app through the app icon (not from push notification )

如果应用程序处于后台且通知已来,用户通过应用程序图标(不是来自推送消息)进入应用程序,在这种情况下也是

if app is in background and notification came and user enters to app through app icon (not from push message ) in this case also

然后我搜索了解决方案,并了解了静音推送通知(对于后台模式),没有其他所以我需要知道如何通过推送通知和我的appdelegete来处理所有场景

Then i searched for solutions and came to know about silent push notifications (for background mode) and nothing else so i need to know how to handle all scenarios by push notifications and my appdelegete is

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];


    if (remoteNotif) {

        [self handlePushMessage:remoteNotif];
    }
    return YES;
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    [self handlePushMessage:userInfo];

}

-(void)handlePushMessage :(NSDictionary*)userInfo{

   //method to handle push message
}

提前致谢

推荐答案

这是一个常见问题:如果用户没有通过显示的通知打开您的应用程序,则无法获取相关信息。

This is a common issue: if the user does not open your app by means of the displayed notification, there is no* way of getting the related information.

*许多应用程序采用的可能解决方案是检查远程服务器是否有未读通知(例如,检查未设置的读取日期字段)。

* A possible solution employed by many apps is to check with a remote server for unread notifications (e.g. check for an unset read-date field).

这篇关于通过单击应用程序图标直接启动应用程序时,无法推送通知数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆