UIApplicationLaunch由remoteNotification swift 3无法正常工作

时间:2016-09-20 09:46:56

标签: swift push-notification swift3

我在swift 2.2中正常工作但是当我转换为swift 3.0然后得到错误。

//If app open by notification
if launchOptions != nil
{
     NSLog("launch------ %@", launchOptions!)

     let  userInfo = launchOptions!(UIApplicationLaunchOptionsKey.remoteNotification) as NSDictionary
     if userInfo != nil
     {
         self.application(UIApplication.shared, didReceiveRemoteNotification: (userInfo)! as! [NSObject : AnyObject])
     }
}

错误如

  

无法调用非函数类型的值'[NSObject:Any]'

提前致谢。

2 个答案:

答案 0 :(得分:1)

最后我修好了: -

if launchOptions != nil
{
     NSLog("launch------ %@", launchOptions!)
     let  userInfo = launchOptions![UIApplicationLaunchOptionsKey.remoteNotification] as! NSDictionary
     if userInfo != nil
     {
         self.application(UIApplication.shared, didReceiveRemoteNotification:(userInfo) as! [AnyHashable : Any] as! [String : AnyObject])
     }
}

答案 1 :(得分:1)

我对Swift 3的解决方案。我必须使用一些强制转换来获取值:

RewriteEngine on
RewriteBase /

RewriteRule ^blog$ www.domain.com/blog?date[]=thedate&date[]=thesnddate&title=sometitle