您能帮我检查一下在配置过程中是否遗漏了什么吗?因为一旦应用程序被杀死,我就无法收到通知了。如果应用程序只是在最小化,就会显示一个呼叫通知,但对于即时消息,手机只会随着流行音乐震动,但没有显示任何通知。使用C2Call如何在AppDelegate子类中调用下面的方法。
[super application:didRegisterForRemoteNotificationsWithDeviceToken];
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
//[self registerDeviceToken:devToken];
// Get Bundle Info for Remote Registration (handy if you have more than one app)
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
// Check what Notifications the user has turned on. We registered for all three, but they may have manually disabled some or all of them.
//
NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
// Set the defaults to disabled unless we find otherwise...
NSString *pushBadge = @"disabled";
NSString *pushAlert = @"disabled";
NSString *pushSound = @"disabled";
if(rntypes == UIRemoteNotificationTypeBadge){
pushBadge = @"enabled";
}
else if(rntypes == UIRemoteNotificationTypeAlert){
pushAlert = @"enabled";
}
else if(rntypes == UIRemoteNotificationTypeSound){
pushSound = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)){ pushBadge = @"enabled";
pushAlert = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)){ pushBadge = @"enabled";
pushSound = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)){ pushAlert = @"enabled";
pushSound = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)){
pushBadge = @"enabled";
pushAlert = @"enabled";
pushSound = @"enabled";
}
// Get the users Device Model, Display Name, Unique ID, Token & Version Number
UIDevice *dev = [UIDevice currentDevice];
// NSString *deviceUuid=dev.uniqueIdentifier;
NSString *deviceUuid = [[dev identifierForVendor] UUIDString];
NSString *deviceName = dev.name;
NSString *deviceModel = dev.model;
NSString *deviceSystemVersion = dev.systemVersion;
//Prepare the Device Token for Registration (remove spaces and < >)
NSString *deviceToken = [[[[devToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString: @" " withString: @""];
NSString *urlString = [@"/pushservice/apns/user/register"stringByAppendingString:@"r=user/register"];
NSLog(@"devicetoken length: %i", [deviceToken length]);
urlString = [urlString stringByAppendingString:@"&appname="];
urlString = [urlString stringByAppendingString:appName];
urlString = [urlString stringByAppendingString:@"&appversion="];
urlString = [urlString stringByAppendingString:appVersion];
urlString = [urlString stringByAppendingString:@"&deviceuid="];
urlString = [urlString stringByAppendingString:deviceUuid];
urlString = [urlString stringByAppendingString:@"&devicetoken="];
urlString = [urlString stringByAppendingString:deviceToken];
urlString = [urlString stringByAppendingString:@"&devicename="];
urlString = [urlString stringByAppendingString:deviceName];
urlString = [urlString stringByAppendingString:@"&devicemodel="];
urlString = [urlString stringByAppendingString:deviceModel];
urlString = [urlString stringByAppendingString:@"&deviceversion="];
urlString = [urlString stringByAppendingString:deviceSystemVersion];
urlString = [urlString stringByAppendingString:@"&pushbadge="];
urlString = [urlString stringByAppendingString:pushBadge];
urlString = [urlString stringByAppendingString:@"&pushalert="];
urlString = [urlString stringByAppendingString:pushAlert];
urlString = [urlString stringByAppendingString:@"&pushsound="];
urlString = [urlString stringByAppendingString:pushSound];
NSUserDefaults *def=[NSUserDefaults standardUserDefaults];
[def setObject:deviceToken forKey:@"token"];
[def synchronize];
//[super application:didRegisterForRemoteNotificationsWithDeviceToken];
}发布于 2014-11-04 05:36:29
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
[super application:didRegisterForRemoteNotificationsWithDeviceToken];
//[self registerDeviceToken:devToken];
// Get Bundle Info for Remote Registration (handy if you have more than one app)
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
// Check what Notifications the user has turned on. We registered for all three, but they may have manually disabled some or all of them.
//
NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
// Set the defaults to disabled unless we find otherwise...
NSString *pushBadge = @"disabled";
NSString *pushAlert = @"disabled";
NSString *pushSound = @"disabled";
if(rntypes == UIRemoteNotificationTypeBadge){
pushBadge = @"enabled";
}
else if(rntypes == UIRemoteNotificationTypeAlert){
pushAlert = @"enabled";
}
else if(rntypes == UIRemoteNotificationTypeSound){
pushSound = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)){ pushBadge = @"enabled";
pushAlert = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)){ pushBadge = @"enabled";
pushSound = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)){ pushAlert = @"enabled";
pushSound = @"enabled";
}
else if(rntypes == ( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)){
pushBadge = @"enabled";
pushAlert = @"enabled";
pushSound = @"enabled";
}
// Get the users Device Model, Display Name, Unique ID, Token & Version Number
UIDevice *dev = [UIDevice currentDevice];
// NSString *deviceUuid=dev.uniqueIdentifier;
NSString *deviceUuid = [[dev identifierForVendor] UUIDString];
NSString *deviceName = dev.name;
NSString *deviceModel = dev.model;
NSString *deviceSystemVersion = dev.systemVersion;
//Prepare the Device Token for Registration (remove spaces and < >)
NSString *deviceToken = [[[[devToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString: @" " withString: @""];
NSString *urlString = [@"/pushservice/apns/user/register"stringByAppendingString:@"r=user/register"];
NSLog(@"devicetoken length: %i", [deviceToken length]);
urlString = [urlString stringByAppendingString:@"&appname="];
urlString = [urlString stringByAppendingString:appName];
urlString = [urlString stringByAppendingString:@"&appversion="];
urlString = [urlString stringByAppendingString:appVersion];
urlString = [urlString stringByAppendingString:@"&deviceuid="];
urlString = [urlString stringByAppendingString:deviceUuid];
urlString = [urlString stringByAppendingString:@"&devicetoken="];
urlString = [urlString stringByAppendingString:deviceToken];
urlString = [urlString stringByAppendingString:@"&devicename="];
urlString = [urlString stringByAppendingString:deviceName];
urlString = [urlString stringByAppendingString:@"&devicemodel="];
urlString = [urlString stringByAppendingString:deviceModel];
urlString = [urlString stringByAppendingString:@"&deviceversion="];
urlString = [urlString stringByAppendingString:deviceSystemVersion];
urlString = [urlString stringByAppendingString:@"&pushbadge="];
urlString = [urlString stringByAppendingString:pushBadge];
urlString = [urlString stringByAppendingString:@"&pushalert="];
urlString = [urlString stringByAppendingString:pushAlert];
urlString = [urlString stringByAppendingString:@"&pushsound="];
urlString = [urlString stringByAppendingString:pushSound];
NSUserDefaults *def=[NSUserDefaults standardUserDefaults];
[def setObject:deviceToken forKey:@"token"];
[def synchronize];
}发布于 2014-11-04 12:47:57
使用以下代码:--
}
https://stackoverflow.com/questions/26713810
复制相似问题