gpt4 book ai didi

iphone - didFinishLaunchingWithOptions 未调用

转载 作者:行者123 更新时间:2023-12-03 19:34:42 25 4
gpt4 key购买 nike

我在启用推送通知时遇到问题。

使用此代码,我尝试启用通知:

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

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationType)(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

return YES;
}

它不起作用,所以我在该行中添加了一个断点

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationType)(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

但这部分代码似乎永远不会执行。

为什么这不起作用?

最佳答案

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

这应该在您的 UIApplicationDelegate 中实现,而不是在 UIViewController 中实现。如果你的 UIViewController 中有它,它永远不会被调用。从那里取出代码并将其放入您的 UIApplicationDelegate 中。

关于iphone - didFinishLaunchingWithOptions 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13877309/

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