iOS 获取token笔记
2014-05-07 12:35
489 查看
//注册
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow
alloc] initWithFrame:[[UIScreen
mainScreen] bounds]];
// Override point for customization after application launch.
[[UIApplication
sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
self.indexVC = [[IndexViewController
alloc]
init];
self.window.rootViewController =
self.indexVC;
self.window.backgroundColor = [UIColor
whiteColor];
[self.window
makeKeyAndVisible];
return
YES;
}
//协议
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData
*)deviceToken
{
NSLog(@"deviceToken -- >> %@",deviceToken);
NSString *pushToken = [[[[deviceToken
description]
stringByReplacingOccurrencesOfString:@"<"
withString:@""]
stringByReplacingOccurrencesOfString:@">"
withString:@""]
stringByReplacingOccurrencesOfString:@" "
withString:@""];
[[NSUserDefaults
standardUserDefaults] setObject:pushToken
forKey:@"Devicetoken"];
[[NSUserDefaults
standardUserDefaults] synchronize];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow
alloc] initWithFrame:[[UIScreen
mainScreen] bounds]];
// Override point for customization after application launch.
[[UIApplication
sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
self.indexVC = [[IndexViewController
alloc]
init];
self.window.rootViewController =
self.indexVC;
self.window.backgroundColor = [UIColor
whiteColor];
[self.window
makeKeyAndVisible];
return
YES;
}
//协议
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData
*)deviceToken
{
NSLog(@"deviceToken -- >> %@",deviceToken);
NSString *pushToken = [[[[deviceToken
description]
stringByReplacingOccurrencesOfString:@"<"
withString:@""]
stringByReplacingOccurrencesOfString:@">"
withString:@""]
stringByReplacingOccurrencesOfString:@" "
withString:@""];
[[NSUserDefaults
standardUserDefaults] setObject:pushToken
forKey:@"Devicetoken"];
[[NSUserDefaults
standardUserDefaults] synchronize];
}
相关文章推荐
- 开源中国iOS客户端学习——(四)GCDiscreetNotificationView提示视图
- 开源中国iOS客户端学习——(七)MBProgressHUD特效
- ios打开手机另一个应用的指定的页面
- iOS开发中那些高效常用的宏
- iOS中创建自定义的圆角按钮
- iOS开发技巧 -- 复用代码片段
- IOS文件操作
- 应用国际化
- ios 精品推荐 永久删除
- WebViewJavascriptBridge-优秀开源代码解读:JS与iOS Native Code互调
- IOS沙盒(sandbox)机制和文件操作
- iOS开发之友盟统计SDK的使用
- iOS沙盒机制
- ios 将NSLog日志重定向输出到文件中保存(2)
- iOS 开源项目list
- IOS #ifdef 的那些事儿
- 关于iOS沙盒路径问题
- ios 将NSLog日志重定向输出到文件中保存
- iOS开发工具——统计Crash的工具Crashlytics
- iOS CoreAnimation