Iphone 方法来处理发送推送通知时出现的错误

Iphone 方法来处理发送推送通知时出现的错误,iphone,ios,push-notification,apple-push-notifications,sendmessage,Iphone,Ios,Push Notification,Apple Push Notifications,Sendmessage,我正在制作iOS通知服务。但我的设备没有收到任何东西,我只是从互联网上获取了一个教程并制作了它 我一次发送多个通知,可能就是这个问题?我已经正确实现了我的应用程序(我可以在“设置”中看到它) 对我来说正确的问题是。。。是否有一些方法可以用来查看是否有代码来处理发送通知时的错误 谢谢。在中,请查看: 表5-1错误响应中的代码 小包 您将找到您要搜索的内容。在中,查看: 表5-1错误响应中的代码 小包 您将找到您搜索的内容。您好,pushnotification中有以下几种方法 首先通过以下方式注册

我正在制作iOS通知服务。但我的设备没有收到任何东西,我只是从互联网上获取了一个教程并制作了它

我一次发送多个通知,可能就是这个问题?我已经正确实现了我的应用程序(我可以在“设置”中看到它)

对我来说正确的问题是。。。是否有一些方法可以用来查看是否有代码来处理发送通知时的错误

谢谢。

在中,请查看:

表5-1错误响应中的代码 小包

您将找到您要搜索的内容。

在中,查看:

表5-1错误响应中的代码 小包


您将找到您搜索的内容。

您好,pushnotification中有以下几种方法

首先通过以下方式注册您的设备:

    [[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 ];

}
-(无效)应用程序:(UIApplication*)应用程序注册器用于删除与DeviceToken:(NSData*)devToken相关的信息
{
NSLog(@“Before---Token===%@”,devToken);
NSString*strServerResponse=[[devToken description]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@”“]]复制];
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(@“编码后---Token===%@”,encodedURL);
}
-(无效)应用程序:(UIApplication*)应用程序未能注册远程通知错误:(N错误*)错误
{
NSLog(@“注册错误。错误:%@”,错误);
}
-(无效)应用程序:(UIApplication*)应用程序DidReceiveMemotentification:(NSDictionary*)用户信息
{
NSLog(@“userInfo%@”,userInfo);
[UIApplication sharedApplication].networkActivityIndicatorVisible=TRUE;
NSLog(@“\n\n从推送通知接收的数据===%@,[userInfo description]);
[[UIApplication sharedApplication]设置应用程序徽章编号:0];
}

您好,pushnotification中有以下几种方法

首先通过以下方式注册您的设备:

    [[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 ];

}
-(无效)应用程序:(UIApplication*)应用程序注册器用于删除与DeviceToken:(NSData*)devToken相关的信息
{
NSLog(@“Before---Token===%@”,devToken);
NSString*strServerResponse=[[devToken description]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@”“]]复制];
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(@“编码后---Token===%@”,encodedURL);
}
-(无效)应用程序:(UIApplication*)应用程序未能注册远程通知错误:(N错误*)错误
{
NSLog(@“注册错误。错误:%@”,错误);
}
-(无效)应用程序:(UIApplication*)应用程序DidReceiveMemotentification:(NSDictionary*)用户信息
{
NSLog(@“userInfo%@”,userInfo);
[UIApplication sharedApplication].networkActivityIndicatorVisible=TRUE;
NSLog(@“\n\n从推送通知接收的数据===%@,[userInfo description]);
[[UIApplication sharedApplication]设置应用程序徽章编号:0];
}