美文网首页
ios 应用启动方式判断

ios 应用启动方式判断

作者: idream | 来源:发表于2017-05-03 17:17 被阅读67次

// 启动类型的枚举变量

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) {

// 有远程通知

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调用

NSURL* launchURL = (NSURL*)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];

if(launchURL) {

startType =  STARTUP_TPYE_BY_SCHEME;

}

} else {

startType = STARTUP_TPYE_BY_NOMAL;

}

return startType;

}

相关文章

网友评论

      本文标题:ios 应用启动方式判断

      本文链接:https://www.haomeiwen.com/subject/arcltxtx.html