【问题标题】:How the App get the notification from APNS when it open应用程序打开时如何从 APNS 获取通知
【发布时间】:2018-04-17 12:57:14
【问题描述】:

iphone收到APNS的通知后,我们打开app,app如何从通知中获取消息 首先,我认为系统会将消息存储在通知中,但是在我尝试过之后,我不这么认为。当我们打开应用程序时,它是否再次向APNS发送请求? (我在QQ里试了一下,收到APNS的通知后,我断开了网络,然后我打开了APP,但是QQ里收不到新消息)

get notification with connecting the Internet

disconnect before open QQ

收到通知后,我没有点击它。并断开网络。然后打开QQ。但是QQ没有收到消息——“hello7”之前通知发送的内容。

【问题讨论】:

  • 你到底想知道什么?
  • 当通知发送到我的iphone时,我的iOS系统会在通知中的某个地方存储消息吗?
  • 通知中心将数据存储在本地。每当您点击通知时,它都会将数据发送到您的应用。
  • 如果我没有点击通知,数据会被存储吗?
  • 如果您收到通知,则说明您的设备有数据。是否点击通知并不重要。

标签: ios notifications apple-push-notifications


【解决方案1】:

设备收到推送通知时系统调用didReceiveRemoteNotification委托方法

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo  {
    application.applicationIconBadgeNumber = 0;            

    if (application.applicationState == UIApplicationStateActive) {                
        // Nothing to do if applicationState is Inactive, the iOS already displayed an alert view.                
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification" message:[NSString stringWithFormat:@"Your App name received this notification while it was running:\n%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];          
    }    
}

【讨论】:

  • 我知道。我想问的是如何获取useInfo?是否将请求发送到 APNS 以获取它?或者从存储中获取?(我在打开应用程序之前断开互联网。我没有收到新消息)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-01-08
  • 1970-01-01
  • 1970-01-01
  • 2013-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多