我已经按照本教程http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
如教程中所述,通知已从服务器成功发送。但我没有在我的设备中得到它。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
if(![[NSUserDefaults standardUserDefaults] valueForKey:@"UUID"])
{
if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
{
deviceID = [self GetUUID];
}
else
{
NSUUID* udid= [UIDevice currentDevice].identifierForVendor;
deviceID = [udid UUIDString];
}
[[NSUserDefaults standardUserDefaults] setValue:deviceID forKey:@"UUID"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
else
{
deviceID = [[NSUserDefaults standardUserDefaults] valueForKey:@"UUID"];
}
return YES; }
- (NSString *)GetUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return (__bridge NSString *)string; }