123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // AppDelegate+sdk.m
- // Overseas Watch
- //
- // Created by 刘振兴 on 2023/11/28.
- // Copyright © 2023 BaH Cy. All rights reserved.
- //
- #import "AppDelegate+sdk.h"
- #import <FBSDKCoreKit/FBSDKCoreKit.h>
- #import <GoogleSignIn/GoogleSignIn.h>
- #import <UMMobClick/MobClick.h>
- #import <Bugly/Bugly.h>
- #import "IQKeyboardManager.h"
- #import "IanAdsStartView.h"
- #import "SKWebViewViewController.h"
- @implementation AppDelegate (sdk)
- + (void)initSdk:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-
- //[MobClick setLogEnabled:YES];
- UMConfigInstance.appKey = @"55a46a7667e58ef87a004b64";
- UMConfigInstance.secret = @"secretstringaldfkals";
- [MobClick startWithConfigure:UMConfigInstance];
-
- [Bugly startWithAppId:@"b77c7f7dbd"];
-
- #ifdef SK_DEBUG_GOOGLE_FACEBOOK
- //plist 中添加
- [[GIDSignIn sharedInstance] restorePreviousSignInWithCompletion:^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {
- }];
-
- //TMO 第三方登录
- [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
- [FBSDKProfile setIsUpdatedWithAccessTokenChange:YES];
- #endif
- }
- + (void)initIQKeyboard {
- //自动伸缩键盘
- IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
- manager.enable = YES;
- manager.shouldResignOnTouchOutside = YES;
- manager.shouldToolbarUsesTextFieldTintColor = YES;
- manager.enableAutoToolbar = NO;
- }
- + (void)showAdvertising {
- //开屏广告
- NSString *adsString = [[NSUserDefaults standardUserDefaults] objectForKey:@"Key_LaunchAds"];
- //@"http://785j3g.com1.z0.glb.clouddn.com/d659db60-f.jpg";
- if ([adsString isKindOfClass:[NSNull class]] || adsString == nil || [adsString isEqualToString:@""])
- return;
-
- NSDictionary* adsDic = [SKUtil parseString2Dictionary:adsString];
- NSString* picUrl = adsDic[@"ImageUrl"];
- if ([picUrl isKindOfClass:[NSNull class]] || picUrl != nil || [picUrl isEqualToString:@""])
- return;
-
- IanAdsStartView *startView = [IanAdsStartView startAdsViewWithBgImageUrl:picUrl withClickImageAction:^{
- NSString *title = adsDic[@"Title"];
- NSString *url = adsDic[@"AdUrl"];
- UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
- SKWebViewViewController *webVc = [storyboard instantiateViewControllerWithIdentifier:@"WebViewVC"];
- webVc.title = title;
- webVc.urlToOpen = url;
- webVc.mIsShare = YES;
- webVc.mIsOpenApp = YES;
- [SKUtil pushViewController:webVc animated:YES];
- }];
- [startView startAnimationTime:3 WithCompletionBlock:^(IanAdsStartView *startView){
- NSLog(@"广告结束后,执行事件");
- }];
- }
- + (void)monitorNetworking {
- [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
- switch (status) {
- case AFNetworkReachabilityStatusUnknown://未知网络
- case AFNetworkReachabilityStatusNotReachable://网络不可达
- HDNormalLog(@"NETWORK --> 0");
- [[NSNotificationCenter defaultCenter] postNotificationName:@"MONITORS_NETWORKING_STATUS" object:@(0)];
- break;
- case AFNetworkReachabilityStatusReachableViaWWAN://GPRS网络
- case AFNetworkReachabilityStatusReachableViaWiFi://wifi网络
- HDNormalLog(@"NETWORK --> 1");
- [[NSNotificationCenter defaultCenter] postNotificationName:@"MONITORS_NETWORKING_STATUS" object:@(1)];
- break;
- }
- }];
- [[AFNetworkReachabilityManager sharedManager] startMonitoring];
- }
- + (void)create3DTouch {
- NSMutableArray *arrShortcutItem = (NSMutableArray *)[UIApplication sharedApplication].shortcutItems;
- if (arrShortcutItem.count <= 0) {
- UIApplicationShortcutItem *shoreItem1 = [[UIApplicationShortcutItem alloc] initWithType:@"3DTouch.Btn.First" localizedTitle:NSLocalizedString(@"Location.Btn.Call", nil) localizedSubtitle:nil icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"3DTouch1"] userInfo:nil];
- [arrShortcutItem addObject:shoreItem1];
-
- UIApplicationShortcutItem *shoreItem2 = [[UIApplicationShortcutItem alloc] initWithType:@"3DTouch.Btn.Second" localizedTitle:NSLocalizedString(@"Tabbar.Chat", nil) localizedSubtitle:nil icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"3DTouch2"] userInfo:nil];
- [arrShortcutItem addObject:shoreItem2];
-
- UIApplicationShortcutItem *shoreItem3 = [[UIApplicationShortcutItem alloc] initWithType:@"3DTouch.Btn.Third" localizedTitle:NSLocalizedString(@"Tabbar.Watch", nil) localizedSubtitle:nil icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"3DTouch3"] userInfo:nil];
- [arrShortcutItem addObject:shoreItem3];
-
- [UIApplication sharedApplication].shortcutItems = arrShortcutItem;
- }
- }
- - (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
- if (@available(iOS 9.0, *)) {
-
- if ([[SKDataManager shared] getChildCount] <= 0)
- return;
-
- if ([shortcutItem.type isEqualToString:@"3DTouch.Btn.First"]) {
- NSString* phoneNum = [SKDataManager shared].mSelectChildModel.phoneNumber;
- if (phoneNum == nil || [phoneNum length] <= 0 )
- return;
-
- //E164
- NSString* nationCode = [SKDataManager shared].mSelectChildModel.areaCode;
- phoneNum = [SKUtil parsePhoneNumber:phoneNum countryCode:nationCode];
-
- phoneNum = [@"tel://" stringByAppendingString:phoneNum];
- if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:phoneNum]]) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNum] options:@{} completionHandler:^(BOOL success) {
- }];
- }
- } else if ([shortcutItem.type isEqualToString:@"3DTouch.Btn.Second"]) {
- UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController;
- UITabBarController* tabbar = (UITabBarController*)controller;
- if (tabbar) {
- [tabbar setSelectedIndex:1];
- }
- } else if ([shortcutItem.type isEqualToString:@"3DTouch.Btn.Third"]) {
- UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController;
- UITabBarController* tabbar = (UITabBarController*)controller;
- if (tabbar) {
- [tabbar setSelectedIndex:2];
- }
- }
- }
- }
- @end
|