gpt4 book ai didi

ios - 检测应用程序是否从推送通知启动/打开

转载 作者:IT王子 更新时间:2023-10-29 07:26:41 27 4
gpt4 key购买 nike

是否可以通过推送通知了解应用是否已启动/打开?

我想启动事件可以在这里捕获:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

if (launchOptions != nil) {
// Launched from push notification
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

}
}

但是,当应用程序处于后台时,如何从推送通知中检测到它已打开?

最佳答案

查看这段代码:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground )
{
//opened from a push notification when the app was on background
}
}

一样
-(void)application:(UIApplication *)application didReceiveLocalNotification (UILocalNotification *)notification

关于ios - 检测应用程序是否从推送通知启动/打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16393673/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com