標籤:out tle use .net type sda cancel art otto
第一步:申請認證:
第二步:申請app ids,應用程式名稱字必須一致。然後再進入進行編輯。使其enable,綠燈。
第三步:申請provisioning profile,產生.mobileprovision,雙擊該認證才幹正確匯入手機裝置。不能拖。
第四步:建立應用。使其名字一致。
第五步:寫代碼
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// return YES;
UIRemoteNotificationType types =
(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert);
//注冊訊息推送
[[UIApplicationsharedApplication]registerForRemoteNotificationTypes:types];
return YES;
}
//擷取DeviceToken成功
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(@"DeviceToken: {%@}",deviceToken);
//這裡進行的操作,是將Device Token發送到服務端
UIAlertView * alert = [[UIAlertViewalloc]initWithTitle:nilmessage:[NSStringstringWithFormat:@"DeviceToken:%@",deviceToken]delegate:selfcancelButtonTitle:nilotherButtonTitles:@"確定",nil];
[alertshow];
}
//注冊訊息推送失敗
- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Register Remote Notifications error:{%@}",error);
// NSLog(@"Register Remote Notifications error:{%@}",error.localizedDescription);
}
//處理收到的訊息推送
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"Receive remote notification : %@",userInfo);
UIAlertView *alert =
[[UIAlertViewalloc] initWithTitle:@"溫馨提示"
message:@"推送成功。"
delegate:nil
cancelButtonTitle:@"確定"
otherButtonTitles:nil];
[alertshow];
}
iOS 推送 擷取手機裝置的 deviceToken