gpt4 book ai didi

iphone - 本地通知问题

转载 作者:行者123 更新时间:2023-12-03 17:54:38 26 4
gpt4 key购买 nike

一旦进程完成,我就会发送本地通知,并且效果很好。

这是我的 didReceiveLocalNotification 代码:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{

CounterViewController *counterVC = [CounterViewController sharedInstance];
[counterVC notificationArrived];
}

但是当 iPhone 锁定时,这些线路不会被调用……我该怎么做才能让它们在后台运行?

最佳答案

有两种接收本地通知的方法,一种是您已经实现的,在应用程序运行时调用,第二种是在 didFinishLaunchingWithOptions 中,当您的应用程序在后台运行时调用,您已经添加了一些代码来接收本地通知... ..

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

// Override point for customization after application launch.

// Add the view controller's view to the window and display.


application.applicationIconBadgeNumber = 0;

// Handle launching from a notification
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(@"Recieved Notification %@",localNotif);
}

return YES;

}

关于iphone - 本地通知问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15493154/

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