在一个 Swift AppDelegate 类中,你会得到以下方法:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// ...code...
return true
}
launchOptions: [NSObject: AnyObject]?
参数是可选的。在Objective-C中,这被传递为NSDictionary
。我想从中提取UIApplicationLaunchOptionsRemoteNotificationKey
。以下是Objective-C中的操作方法:
NSDictionary *remoteNotification = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotification)
{
// ...do stuff...
}
你如何在Swift中实现这个功能?