// 啟動(dòng)類(lèi)型的枚舉變量
typedef NS_ENUM(NSUInteger, STARTUP_TPYE)
{
STARTUP_TPYE_BY_NOMAL = 0,
STARTUP_TPYE_BY_NOTIFICATION,
STARTUP_TPYE_BY_PUSH,
STARTUP_TPYE_BY_SCHEME,
};
- (STARTUP_TPYE)checkStartUpType:(NSDictionary *)launchOptions
{
STARTUP_TPYE startType = STARTUP_TPYE_BY_NOMAL;
if (launchOptions) {
// 有遠(yuǎn)程通知
NSDictionary *payload = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (payload) {
startType =? STARTUP_TPYE_BY_PUSH;
}
// 有本地通知
UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotification) {
startType =? STARTUP_TPYE_BY_NOTIFICATION;
}
// 有第三方APP調(diào)用
NSURL* launchURL = (NSURL*)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
if(launchURL) {
startType =? STARTUP_TPYE_BY_SCHEME;
}
} else {
startType = STARTUP_TPYE_BY_NOMAL;
}
return startType;
}