我将用户名、密码和设备令牌的值发布到 .net 网络服务。但它没有获得任何设备令牌值。我正在使用下面的代码。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert ];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken: %@", deviceToken);
NSString *dt = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
dt = [dt stringByReplacingOccurrencesOfString:@" " withString:@""];
self.DeviceToken=dt;
NSLog(@"~~~~devToken(dv)=%@",deviceToken);
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
但在控制台中它显示
获取令牌失败,错误:错误域 = NSCocoaErrorDomain 代码 = 3000 “找不到应用程序的有效 'aps-environment' 权利字符串” UserInfo=0x1a0810 {NSLocalizedDescription=找不到应用程序的有效 'aps-environment' 权利字符串
任何的想法?提前致谢!