//禁止横屏
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//欢迎页显示3秒
[NSThread sleepForTimeInterval:2.0];
//纪录用户登录信息
[[[CommenData alloc]init] gatherMessage];
//纪录判断用户是否首次打开
NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
if (![userDefaults boolForKey:@"firstLoad"]) {
UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
WelcomeViewController *w=[story instantiateViewControllerWithIdentifier:@"firstPage"];
self.window.rootViewController=w;
[userDefaults setBool:YES forKey:@"firstLoad"];
[userDefaults synchronize];
}
//初始化社会化分享
[ShareSDK registerApp:@"45df0da85a70"];
//
// //添加新浪微博应用 注册网址 http://open.weibo.com
// [ShareSDK connectSinaWeiboWithAppKey:@"568898243"
// appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
// redirectUri:@"http://inav.int-yt.cn"];
//添加QQ应用 注册网址 http://open.qq.com/
[ShareSDK connectQQWithQZoneAppKey:@"1102001449"
qqApiInterfaceCls:[QQApiInterface class]
tencentOAuthCls:[TencentOAuth class]];
//添加微信应用 注册网址 http://open.weixin.qq.com
NSString *appId = @"wx659eb9e9ffd5abc4";
[ShareSDK connectWeChatSessionWithAppId: appId wechatCls:[WXApi class]];
// 初始化消息推送
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
//可以添加自定义categories
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
} else {
//categories 必须为nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
}
#else
//categories 必须为nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
#endif
// Required
[APService setupWithOption:launchOptions];
[APService setBadge:0];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0 ];
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
NSString *pushStatus = [defaults objectForKey:@"status"];//根据键值取出status
if([pushStatus isEqualToString:@"off"]){
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
}
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidReceiveMessageNotification object:nil];
return YES;
}
appdelegate 设置
最新推荐文章于 2021-12-15 11:24:07 发布