gpt4 book ai didi

ios - 尽管我收到通知,但 Didreceivenotification 从未被调用

转载 作者:行者123 更新时间:2023-11-29 10:43:09 25 4
gpt4 key购买 nike

(void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo ;

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:
  (NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult
result))completionHandler{};

从来没有接到电话,虽然我在 iphone 上收到通知,是否需要添加任何其他功能才能正常工作?谢谢。

更新当应用程序不在后台也不处于事件状态但我没有收到消息时,我尝试了此操作。 - (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //为 |GPPSignIn| 设置应用程序的客户端 ID和 |GPPShare|。

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

// Clear application badge when app launches
application.applicationIconBadgeNumber = 0;
if ([[launchOptions allKeys] containsObject:UIApplicationLaunchOptionsRemoteNotificationKey]) {

id userInfo=[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"MESSAGE" message:userInfo delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alert show];
}

最佳答案

如果您的应用程序关闭并收到通知......

didFinishLaunchingWithOptions中添加以下代码

if ([[launchOptions allKeys] containsObject:UIApplicationLaunchOptionsRemoteNotificationKey]) 
{
id userInfo=[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSLog(@"%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]);
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"MESSAGE" message:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"] delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alert show];
}

但是当你点击通知时这个调用

关于ios - 尽管我收到通知,但 Didreceivenotification 从未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23470427/

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