- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 navBased 应用程序中处理推送通知。在 AppDelegate.m didRegisterForRemoteNotificationsWithDeviceToken: 调用 registerForRemoteNotificationTypes 时不会调用:代码如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Get a hex string from the device token with no spaces or < >
NSLog(@"applicationDidFinishLaunchingWithOptions dev token test");
NSString *deviceTokenStr = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"Device Token: %@", deviceTokenStr);
}
我很确定配置文件不是问题。我发现错误:
注册时出错。错误:错误域=NSCocoaErrorDomain代码=3000“找不到应用程序的有效'aps-environment'权利字符串”UserInfo=0x115490 {NSLocalizedDescription=没有找到应用程序的有效'aps-environment'权利字符串}
谁能告诉我这段代码发生了什么并且它不起作用?谢谢
最佳答案
在 Appdelegate didFinishLaunching 方法中输入此代码 -
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
然后将这两个方法复制并粘贴到同一个 appdelegate 中 -
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
NSString *dToken = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
dToken = [dToken stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"STR%@",dToken);
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
关于iphone - didRegisterForRemoteNotificationsWithDeviceToken : doesn't invoke on calling registerForRemoteNotificationTypes:?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4994302/
我需要检查用户是否授予了通知权限,到目前为止我知道只有在授予通知权限时才会调用 didRegisterForRemoteNotificationsWithDeviceToken ,但在某些设备中,无论
即使用户不“接受”接收远程通知,方法 didRegisterForRemoteNotificationsWithDeviceToken 也会被调用吗? 最佳答案 没有。您需要手动跟踪这一点。这是相当基
我正在更新我现有的应用程序。我正在使用推送通知向用户发送消息。当应用程序调用委托(delegate)“didRegisterForRemoteNotificationsWithDeviceToken”
标题说明了一切......我在每次应用程序启动时调用 registerForRemoteNotificationTypes。它第一次工作得很好。获得了设备 token ,但我所做的只是 NSLog。
我只是想确认“didRegisterForRemoteNotificationsWithDeviceToken”是指在每次应用程序加载时调用并且我的 PHP 服务器或应用程序需要处理是否重新提交以存储
有点类似于When is didRegisterForRemoteNotificationsWithDeviceToken called? . 当用户第一次安装应用时,提示是否接受通知,如果用户接受,
这个问题在这里已经有了答案: didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister
有很多关于 didRegisterForRemoteNotificationsWithDeviceToken 的问题,但他们都回避了一个非常直接的问题,我似乎找不到确切的答案。 对于以所有其他方式正确
我已经花了几个小时试图找出为什么 didRegisterForRemoteNotificationsWithDeviceToken 没有被调用。它以前有效。我几个星期没碰它了。现在停止工作了。 这是我
我有两台 iPad mini(ios8.3 和 ios9.1)和一台 iPad mini 2。 在 iPad mini 2 (ios.9.1) 上:运行良好。 在 iPad mini (ios.8.3
我以这种方式通过 Parse 注册推送通知: func application(application: UIApplication, didFinishLaunchingWithOptions la
为什么application:didRegisterForRemoteNotificationsWithDeviceToken接收到的deviceToken是NSData? 我们不是总是将它转换为NS
我正在使用 Parse.com 在我的 iOS 应用程序中发送推送通知。但是当我执行以下代码来创建 PFInstallation 对象时,设备 token 字段为空。 - (void)applicat
我收到回调 didRegisterForRemoteNotificationsWithDeviceToken: ,但是返回给我的数据是空的....所以我不知道设备 token 。 有没有人以前看过这个
调用 didRegisterForRemoteNotificationsWithDeviceToken 时,iOS 会触发 NSNotification(其中包含 deviceToken)吗? 我知道
我正在制作一个我想在其中实现苹果推送通知服务的应用程序。我正在按照 this tutorial 中给出的分步说明进行操作。 . 但是,这些方法仍然没有被调用。我不知道是什么导致了问题。谁能帮帮我?
我正在 navBased 应用程序中处理推送通知。在 AppDelegate.m didRegisterForRemoteNotificationsWithDeviceToken: 调用 regist
我正在尝试在 iPad 中获取设备 token 以用于远程推送通知;registerForRemoteNotificationTypes 被调用没问题,没有错误,但是 didRegisterForRe
我的类协议(protocol)(UIApplicationDelegate) @interface BangAppDelegate : NSObject { UIWindow *window
功能中,同时开启了推送通知和后台模式(远程通知)。 我在主页中检查了 UIApplication.shared.isRegisteredForRemoteNotifications 的值。该值是真实的
我是一名优秀的程序员,十分优秀!