我正在制作iOS通知服务。但我的设备没有收到任何东西,我只是从互联网上获取一个教程并制作它。
我一次发送超过1个通知,也许这是问题所在?我已正确实施我的应用程序(我可以在设置中看到它)。
对我来说,正确的问题是......是否有一些方法可以用来查看是否有任何代码来处理发送通知时的错误?
谢谢。
答案 0 :(得分:3)
答案 1 :(得分:0)
嗨推送通知中的方法很少,如下所示
首先通过
注册您的设备 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
然后使用其委托方法
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
{
NSLog(@"Before --- Token === %@",devToken);
NSString *strServerResponse = [[[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]copy];
NSLog(@"%@",strServerResponse);
NSString * encodedURL = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)strServerResponse,NULL,(CFStringRef)@" ",kCFStringEncodingUTF8 );
NSString *DeviceToken=[Constant getUserDefaultValueForKey:@"DeviceToken"];
if([Constant checkStringNull:DeviceToken])
{
[Constant setUserDefaultValue:encodedURL forKey:@"DeviceToken"];
}
NSLog(@"After Encoding --- Token === %@",encodedURL);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSLog(@"Error in registration. Error: %@", err);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"userInfo %@",userInfo);
[UIApplication sharedApplication].networkActivityIndicatorVisible=TRUE;
NSLog(@"\n\nData Received From Push Notification ===== %@",[userInfo description]);
[[UIApplication sharedApplication]setApplicationIconBadgeNumber:0 ];
}