首页 > 代码库 > iOS APNS远程推送

iOS APNS远程推送




                    真机运行远程推送dome,然后得到下面的device

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

  // 注册远程推送      
   [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound ]; 
}   
  //注册失败时的代理实现  
  - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{ 
          NSLog(@"Error:%@",error);  
 }     
//获得40位的令牌,在推送时需要使用  
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ 
        NSLog(@"DeviceToken :%@",deviceToken);  
 }