【问题标题】:Check if app became active because of RemoteNotification ( App is already launched)检查应用程序是否因为 RemoteNotification 而变为活动状态(应用程序已启动)
【发布时间】:2016-11-09 12:06:30
【问题描述】:

我想区分应用是否响应 RemoteNotification 单击而变为Active。怎么做 ?

【问题讨论】:

    标签: ios swift push


    【解决方案1】:

    你可以这样检查

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
           NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
                    if (notification) {
    
                    // it's launch from notification
    
    
                    }
                    else
                    {
                         // normal launch on app icon click
                    }
    
        }
    

    请快速使用这个

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
            if (launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? NSDictionary) != nil {
    
               // it's launch from notification
                       }
            else
            {
                  // normal launch on app icon click 
            }
    
            // Override point for customization after application launch.
            return true
        }
    

    【讨论】:

      猜你喜欢
      • 2011-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多