ios 退出程序通知后台_在iOS中关闭应用并且应用未在后台运行时,从推送通知获取数据...

When receive a push notification and my application is totally closed, how can handle this info?

Only can get data from NSDictionary on this method didFinishLaunchingWithOptions: or

didReceiveRemoteNotification:

for example: when the user open the application how get data from the push notification?, and not when the user open the push notification directly.

Is there a method that responds and detect if a notification has not been read?

解决方案

You'll want to implement

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler

This will launch your app if needed, then you'll want to save the data somewhere so when the user next's starts the app you grab the data and do something with it.

Discussion

Use this method to process incoming remote notifications for your app.

Unlike the application:didReceiveRemoteNotification: method, which is

called only when your app is running in the foreground, the system

calls this method when your app is running in the foreground or

background. In addition, if you enabled the remote notifications

background mode, the system launches your app (or wakes it from the

suspended state) and puts it in the background state when a push

notification arrives. However, the system does not automatically

launch your app if the user has force-quit it. In that situation, the

user must relaunch your app or restart the device before the system

attempts to launch your app automatically again.

Just look into the method and I'm certain you'll figure it out :)

I did a quick google, these look like they will help:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值