ios – 如何区分应用程序中收到的推送通知和应用程序外部的推送通知?

前端之家收集整理的这篇文章主要介绍了ios – 如何区分应用程序中收到的推送通知和应用程序外部的推送通知?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的应用中设置了推送通知.我有方法
- (void)application:(UIApplication *)application didReceiveRemoteNotification:     (NSDictionary *)userInfo
 {
      if()
      {
           //app is in foreground to get here
      }
      else if()
      {
           //app is in background and then the notification is clicked,to get here
      }
 }

我需要区分应用程序外部通知的触摸,只需在应用程序中接收通知即可.有帮助吗?

解决方法

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if ( application.applicationState == UIApplicationStateActive )
        // app was already in the foreground
    else
        // app was just brought from background to foreground
    ...
}
原文链接:https://www.f2er.com/iOS/327909.html

猜你在找的iOS相关文章