ios 应用启动方式判断

// 启动类型的枚举变量

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;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容