gpt4 book ai didi

iphone - 推送通知不调用该方法

转载 作者:行者123 更新时间:2023-11-29 11:06:16 26 4
gpt4 key购买 nike

我已经在我的应用程序 ID 中启用了生产推送通知,并使用它创建了配置文件。当我在我的 iPad 上运行该应用程序时,它会要求通知,而我收到了相应的通知。但问题是方法

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {

即使我在 didfinishlaunch 中添加了以下代码,也没有调用

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

任何想法请帮助我,我现在正在使用 ios6。

最佳答案

我只是这样暗示:-

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



[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

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

}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

self.strToken = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {

}




- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
NSString *cancelTitle = @"Close";
NSString *showTitle = @"Show";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"myapp name"
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:showTitle, nil];
[alertView show];
[alertView release];


} else {
//Do stuff that you would do if the application was not active
}
}

更新

In Device, Go to Settings->Notifications->YourApp->Enable_Notifications

请检查下面的堆栈溢出问题可能对您有帮助

iOS Registering for Push Notifications within Application

Delegate for "View" for Push Notification

Push Notification delegate call backs are not getting called

Push notification delegate method issue

push notification : both didFailToRegister and didRegister delegate not calling

Push Notification Delegates not getting called

编辑检查设置是否有通知不关闭 enter image description here

关于iphone - 推送通知不调用该方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13487420/

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