From 3b8f57d02f538f00512c94e9708bc6bcdb85b911 Mon Sep 17 00:00:00 2001 From: lianxiang <13052344590@163.com> Date: Wed, 22 Aug 2018 17:53:17 +0800 Subject: [PATCH] =?UTF-8?q?add=20jpush=20=E5=90=AF=E5=8A=A8=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GIGA.xcodeproj/project.pbxproj | 77 ++++++++- GIGA/AppDelegate+GiGaConfig.h | 6 +- GIGA/AppDelegate+GiGaConfig.m | 9 ++ GIGA/AppDelegate+ThirdParty.m | 9 +- GIGA/AppDelegate.m | 13 +- .../Contents.json | 8 + GIGA/Base.lproj/LaunchScreen.storyboard | 12 +- GIGA/Common/GiGaFileManager/GiGaFileNanager.h | 20 +++ GIGA/Common/GiGaFileManager/GiGaFileNanager.m | 68 ++++++++ GIGA/Common/GiGaUserDB/GiGaUserDefault.h | 3 +- GIGA/Common/GiGaUserDB/GiGaUserDefault.m | 1 + GIGA/Config/GIGA.h | 6 +- GIGA/GIGA.entitlements | 8 + GIGA/Info.plist | 14 +- .../GiGaAdDetailViewController.h | 13 ++ .../GiGaAdDetailViewController.m | 38 +++++ .../AppAD/GiGaStartAdView/GiGaStartAdView.h | 28 ++++ .../AppAD/GiGaStartAdView/GiGaStartAdView.m | 151 ++++++++++++++++++ .../LogIn/Controller/GiGaUserLoginVC.m | 10 +- .../Controller/GiGaMaskTaskViewController.m | 29 +++- .../Mask/View/MaskViewBootomWaringView.h | 2 +- .../Me/Controller/GiGaMeViewController.h | 13 ++ .../Me/Controller/GiGaMeViewController.m | 37 +++++ GIGA/ViewController.m | 4 +- 24 files changed, 545 insertions(+), 34 deletions(-) create mode 100644 GIGA/Common/GiGaFileManager/GiGaFileNanager.h create mode 100644 GIGA/Common/GiGaFileManager/GiGaFileNanager.m create mode 100644 GIGA/GIGA.entitlements create mode 100644 GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.h create mode 100644 GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.m create mode 100644 GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.h create mode 100644 GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.m create mode 100644 GIGA/Modules/Me/Controller/GiGaMeViewController.h create mode 100644 GIGA/Modules/Me/Controller/GiGaMeViewController.m diff --git a/GIGA.xcodeproj/project.pbxproj b/GIGA.xcodeproj/project.pbxproj index 0d16e9a..97957cf 100644 --- a/GIGA.xcodeproj/project.pbxproj +++ b/GIGA.xcodeproj/project.pbxproj @@ -19,6 +19,11 @@ 83346AD7212C18F50054D597 /* GiGaAppGaurdVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 83346AD6212C18F50054D597 /* GiGaAppGaurdVC.m */; }; 833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */; }; 8349585C212511040064DB6C /* AppDelegate+ThirdParty.m in Sources */ = {isa = PBXBuildFile; fileRef = 8349585B212511040064DB6C /* AppDelegate+ThirdParty.m */; }; + 835060A2212D1225007E6220 /* GiGaMeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 835060A1212D1225007E6220 /* GiGaMeViewController.m */; }; + 835060A5212D3536007E6220 /* AppDelegate+GiGaConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 8361B40A21217B2100238FEB /* AppDelegate+GiGaConfig.m */; }; + 835060A9212D38EE007E6220 /* GiGaStartAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 835060A8212D38EE007E6220 /* GiGaStartAdView.m */; }; + 835060AD212D4D0C007E6220 /* GiGaFileNanager.m in Sources */ = {isa = PBXBuildFile; fileRef = 835060AC212D4D0C007E6220 /* GiGaFileNanager.m */; }; + 835060B3212D54C2007E6220 /* GiGaAdDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 835060B2212D54C2007E6220 /* GiGaAdDetailViewController.m */; }; 8357ADC52123BEBD000816F2 /* GiGaUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 8357ADC42123BEBD000816F2 /* GiGaUser.m */; }; 8357ADC92123BFCA000816F2 /* GiGaUserManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8357ADC82123BFCA000816F2 /* GiGaUserManager.m */; }; 8357ADCD2123C091000816F2 /* GiGaNetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8357ADCC2123C091000816F2 /* GiGaNetManager.m */; }; @@ -36,7 +41,6 @@ 8361B3EE212155C300238FEB /* GIGAUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8361B3ED212155C300238FEB /* GIGAUITests.m */; }; 8361B40421215E0C00238FEB /* LXCountTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8361B40221215E0C00238FEB /* LXCountTimer.m */; }; 8361B40721215E6F00238FEB /* GiGaHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8361B40621215E6F00238FEB /* GiGaHelper.m */; }; - 8361B40B21217B2100238FEB /* AppDelegate+GiGaConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 8361B40A21217B2100238FEB /* AppDelegate+GiGaConfig.m */; }; 8361B40D21217C8200238FEB /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8361B40C21217C8200238FEB /* CFNetwork.framework */; }; 8361B40F21217C9200238FEB /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8361B40E21217C9100238FEB /* CoreFoundation.framework */; }; 8361B41121217CA100238FEB /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8361B41021217CA100238FEB /* CoreTelephony.framework */; }; @@ -99,6 +103,15 @@ 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMaskTaskViewController.m; sourceTree = ""; }; 8349585A212511040064DB6C /* AppDelegate+ThirdParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+ThirdParty.h"; sourceTree = ""; }; 8349585B212511040064DB6C /* AppDelegate+ThirdParty.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+ThirdParty.m"; sourceTree = ""; }; + 835060A0212D1225007E6220 /* GiGaMeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMeViewController.h; sourceTree = ""; }; + 835060A1212D1225007E6220 /* GiGaMeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMeViewController.m; sourceTree = ""; }; + 835060A3212D2321007E6220 /* GIGA.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GIGA.entitlements; sourceTree = ""; }; + 835060A7212D38EE007E6220 /* GiGaStartAdView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaStartAdView.h; sourceTree = ""; }; + 835060A8212D38EE007E6220 /* GiGaStartAdView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaStartAdView.m; sourceTree = ""; }; + 835060AB212D4D0C007E6220 /* GiGaFileNanager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFileNanager.h; sourceTree = ""; }; + 835060AC212D4D0C007E6220 /* GiGaFileNanager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFileNanager.m; sourceTree = ""; }; + 835060B1212D54C2007E6220 /* GiGaAdDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaAdDetailViewController.h; sourceTree = ""; }; + 835060B2212D54C2007E6220 /* GiGaAdDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaAdDetailViewController.m; sourceTree = ""; }; 8357ADC32123BEBD000816F2 /* GiGaUser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaUser.h; sourceTree = ""; }; 8357ADC42123BEBD000816F2 /* GiGaUser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaUser.m; sourceTree = ""; }; 8357ADC72123BFCA000816F2 /* GiGaUserManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaUserManager.h; sourceTree = ""; }; @@ -229,6 +242,42 @@ path = Source; sourceTree = ""; }; + 835060A6212D38BC007E6220 /* GiGaStartAdView */ = { + isa = PBXGroup; + children = ( + 835060A7212D38EE007E6220 /* GiGaStartAdView.h */, + 835060A8212D38EE007E6220 /* GiGaStartAdView.m */, + ); + path = GiGaStartAdView; + sourceTree = ""; + }; + 835060AA212D4C0F007E6220 /* GiGaFileManager */ = { + isa = PBXGroup; + children = ( + 835060AB212D4D0C007E6220 /* GiGaFileNanager.h */, + 835060AC212D4D0C007E6220 /* GiGaFileNanager.m */, + ); + path = GiGaFileManager; + sourceTree = ""; + }; + 835060AE212D5423007E6220 /* AppAD */ = { + isa = PBXGroup; + children = ( + 835060AF212D5467007E6220 /* GiGaAdDetailViewController */, + 835060A6212D38BC007E6220 /* GiGaStartAdView */, + ); + path = AppAD; + sourceTree = ""; + }; + 835060AF212D5467007E6220 /* GiGaAdDetailViewController */ = { + isa = PBXGroup; + children = ( + 835060B1212D54C2007E6220 /* GiGaAdDetailViewController.h */, + 835060B2212D54C2007E6220 /* GiGaAdDetailViewController.m */, + ); + path = GiGaAdDetailViewController; + sourceTree = ""; + }; 8354B3812121BAE1004F448F /* Controller */ = { isa = PBXGroup; children = ( @@ -307,6 +356,7 @@ 8361B3C8212155C200238FEB /* GIGA */ = { isa = PBXGroup; children = ( + 835060A3212D2321007E6220 /* GIGA.entitlements */, 8361B3FF21215C9D00238FEB /* Modules */, 8361B3FE21215C8A00238FEB /* Category */, 8361B3FD21215C7F00238FEB /* Config */, @@ -350,6 +400,7 @@ 8361B3FC21215C7400238FEB /* Common */ = { isa = PBXGroup; children = ( + 835060AA212D4C0F007E6220 /* GiGaFileManager */, 83346AC8212BD4160054D597 /* Source */, 8357ADCA2123BFD8000816F2 /* GiGaNetTool */, 8357ADC62123BF6D000816F2 /* GiGaUserDB */, @@ -387,6 +438,7 @@ 8361B3FF21215C9D00238FEB /* Modules */ = { isa = PBXGroup; children = ( + 835060AE212D5423007E6220 /* AppAD */, 83E40B3021219078008149C4 /* Mask */, 83E40B2C21218B7E008149C4 /* LogIn */, 8361B42521217FC000238FEB /* GiGaExercises */, @@ -468,6 +520,8 @@ children = ( 83E40B2D21218BA0008149C4 /* GiGaUserViewController.h */, 83E40B2E21218BA0008149C4 /* GiGaUserViewController.m */, + 835060A0212D1225007E6220 /* GiGaMeViewController.h */, + 835060A1212D1225007E6220 /* GiGaMeViewController.m */, ); path = Controller; sourceTree = ""; @@ -626,6 +680,11 @@ TargetAttributes = { 8361B3C5212155C200238FEB = { CreatedOnToolsVersion = 9.4.1; + SystemCapabilities = { + com.apple.Push = { + enabled = 1; + }; + }; }; 8361B3DD212155C300238FEB = { CreatedOnToolsVersion = 9.4.1; @@ -761,9 +820,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 835060AD212D4D0C007E6220 /* GiGaFileNanager.m in Sources */, 83346AC5212BBC8C0054D597 /* GiGaRegistViewController.m in Sources */, 83346AD7212C18F50054D597 /* GiGaAppGaurdVC.m in Sources */, - 8361B40B21217B2100238FEB /* AppDelegate+GiGaConfig.m in Sources */, 8349585C212511040064DB6C /* AppDelegate+ThirdParty.m in Sources */, 8361B3CE212155C200238FEB /* ViewController.m in Sources */, 8361B4382121847600238FEB /* UINavigationBar+Custom.m in Sources */, @@ -774,17 +833,21 @@ 8357ADD82124027D000816F2 /* GiGaUserDefault.m in Sources */, 8361B40721215E6F00238FEB /* GiGaHelper.m in Sources */, 8357ADCD2123C091000816F2 /* GiGaNetManager.m in Sources */, + 835060A9212D38EE007E6220 /* GiGaStartAdView.m in Sources */, 833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */, 8357ADD02123C5F7000816F2 /* GiGaAPIRequest.m in Sources */, 8361B3D9212155C300238FEB /* main.m in Sources */, + 835060A2212D1225007E6220 /* GiGaMeViewController.m in Sources */, 8361B3CB212155C200238FEB /* AppDelegate.m in Sources */, 8361B4322121832800238FEB /* GiGaBaseViewController.m in Sources */, 8357ADD32123C7C6000816F2 /* GiGaAPIResult.m in Sources */, 8361B4352121836700238FEB /* GiGaBaseNavViewController.m in Sources */, + 835060B3212D54C2007E6220 /* GiGaAdDetailViewController.m in Sources */, 83346AC0212BB50A0054D597 /* PassWordResetVC.m in Sources */, 8361B40421215E0C00238FEB /* LXCountTimer.m in Sources */, 8357ADC52123BEBD000816F2 /* GiGaUser.m in Sources */, 83E40B2F21218BA0008149C4 /* GiGaUserViewController.m in Sources */, + 835060A5212D3536007E6220 /* AppDelegate+GiGaConfig.m in Sources */, 83E40B2B21218B6F008149C4 /* GiGaExercisesViewController.m in Sources */, 8361B42E2121812000238FEB /* GiGaServerConfig.m in Sources */, 83A22712212A9EA900B3E75C /* UIView+Sizes.m in Sources */, @@ -959,8 +1022,10 @@ baseConfigurationReference = 055947143A68ADCC68C3F3E1 /* Pods-GIGA.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = GIGA/GIGA.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YYP376WR4X; GCC_PREFIX_HEADER = "$(SRCROOT)//GIGA/GIGA.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -976,7 +1041,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.gigamask.ios; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; + PROVISIONING_PROFILE = "f3b84b1a-7ac9-46d1-bd63-b997256cf85b"; + PROVISIONING_PROFILE_SPECIFIER = jijiaDevelopmentProfile; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -986,6 +1052,8 @@ baseConfigurationReference = F5264C04C5FC282D0E6AB7E5 /* Pods-GIGA.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = GIGA/GIGA.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = ""; GCC_PREFIX_HEADER = "$(SRCROOT)//GIGA/GIGA.pch"; @@ -1003,6 +1071,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.gigamask.ios; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/GIGA/AppDelegate+GiGaConfig.h b/GIGA/AppDelegate+GiGaConfig.h index 7d6a952..dbe7136 100644 --- a/GIGA/AppDelegate+GiGaConfig.h +++ b/GIGA/AppDelegate+GiGaConfig.h @@ -15,6 +15,8 @@ //v1.0 - (void)setupRootVC; - - +/** + 设置启动广告 + */ +-(void)creatAdView; @end diff --git a/GIGA/AppDelegate+GiGaConfig.m b/GIGA/AppDelegate+GiGaConfig.m index 730bbfc..ae1cba2 100644 --- a/GIGA/AppDelegate+GiGaConfig.m +++ b/GIGA/AppDelegate+GiGaConfig.m @@ -10,6 +10,8 @@ #import "GiGaBaseNavViewController.h" #import "GiGaMaskTaskViewController.h" #import "GiGaUserDefault.h" +#import "GiGaStartAdView.h" + @implementation AppDelegate (GiGaConfig) -(void)setupTabBarController{ @@ -77,6 +79,7 @@ // - (void)setupRootVC{ + GiGaMaskTaskViewController *maskeVC = [[GiGaMaskTaskViewController alloc] init]; GiGaBaseNavViewController *maskNav =[[GiGaBaseNavViewController alloc] initWithRootViewController:maskeVC]; maskNav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; @@ -87,4 +90,10 @@ } +-(void)creatAdView{ + + GiGaStartAdView *startadview = [[GiGaStartAdView alloc] initWithFrame:self.window.bounds]; + [startadview show]; +} + @end diff --git a/GIGA/AppDelegate+ThirdParty.m b/GIGA/AppDelegate+ThirdParty.m index 5c5eca3..a65bfea 100644 --- a/GIGA/AppDelegate+ThirdParty.m +++ b/GIGA/AppDelegate+ThirdParty.m @@ -63,20 +63,22 @@ // Required NSDictionary * userInfo = response.notification.request.content.userInfo; + GILog(@"ios(10.0)-userInfo%@",userInfo); if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { [JPUSHService handleRemoteNotification:userInfo]; } completionHandler(); // 系统要求执行这个方法 } -- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler API_AVAILABLE(ios(10.0)){ +- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler API_AVAILABLE(ios(10.0)){ // Required NSDictionary * userInfo = notification.request.content.userInfo; + //GILog(@"userInfo%@",userInfo); if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { [JPUSHService handleRemoteNotification:userInfo]; } - completionHandler(UNNotificationPresentationOptionAlert); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置 + completionHandler(UNNotificationPresentationOptionAlert|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionBadge); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置 } @@ -90,10 +92,10 @@ NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error); } -//ios8 以下本应用可忽略 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // Required, iOS 7 Support + GILog(@"iOS 7 userInfo%@",userInfo); [JPUSHService handleRemoteNotification:userInfo]; completionHandler(UIBackgroundFetchResultNewData); } @@ -102,6 +104,7 @@ // Required,For systems with less than or equal to iOS6 [JPUSHService handleRemoteNotification:userInfo]; + } diff --git a/GIGA/AppDelegate.m b/GIGA/AppDelegate.m index 2de2367..86089bd 100644 --- a/GIGA/AppDelegate.m +++ b/GIGA/AppDelegate.m @@ -10,6 +10,7 @@ #import "AppDelegate+GiGaConfig.h" #import "AppDelegate+ThirdParty.h" #import "GiGaUserDefault.h" +#import "JPUSHService.h" @interface AppDelegate () @@ -20,13 +21,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - [NSThread sleepForTimeInterval:1];//延迟启动 + //[NSThread sleepForTimeInterval:1];//延迟启动 + application.applicationIconBadgeNumber = 0; + [JPUSHService resetBadge]; [self configThridPartyWithOptions:launchOptions]; [self configEnvironment]; - [self setupRootVC]; - + //广告页 + [self creatAdView]; //[self setupTabBarController]; return YES; @@ -39,12 +42,16 @@ - (void)applicationDidEnterBackground:(UIApplication *)application { + + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { + application.applicationIconBadgeNumber = 0; + [JPUSHService resetBadge]; // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. } diff --git a/GIGA/Assets.xcassets/maskTime/maske_dismiss_waring.imageset/Contents.json b/GIGA/Assets.xcassets/maskTime/maske_dismiss_waring.imageset/Contents.json index 0561119..a3523a7 100644 --- a/GIGA/Assets.xcassets/maskTime/maske_dismiss_waring.imageset/Contents.json +++ b/GIGA/Assets.xcassets/maskTime/maske_dismiss_waring.imageset/Contents.json @@ -4,6 +4,14 @@ "idiom" : "universal", "filename" : "maske_dismiss_waring.png", "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/GIGA/Base.lproj/LaunchScreen.storyboard b/GIGA/Base.lproj/LaunchScreen.storyboard index f83f6fd..722ce1c 100644 --- a/GIGA/Base.lproj/LaunchScreen.storyboard +++ b/GIGA/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,11 @@ - - + + + + + - + + @@ -13,7 +17,7 @@ - + diff --git a/GIGA/Common/GiGaFileManager/GiGaFileNanager.h b/GIGA/Common/GiGaFileManager/GiGaFileNanager.h new file mode 100644 index 0000000..d41418c --- /dev/null +++ b/GIGA/Common/GiGaFileManager/GiGaFileNanager.h @@ -0,0 +1,20 @@ +// +// GiGaFileNanager.h +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import +#import +@interface GiGaFileNanager : NSObject + ++(GiGaFileNanager*)shareInstance; +- (BOOL)isFileExistWithFilePath:(NSString *)filePath; +-(NSString *)getFilePathWithImageName:(NSString *)imageName; +-(void)removeItemAtPath:(NSString *)filePath; +- (void)saveAdImageWithUrl:(NSString *)imageUrl imageName:(NSString *)imageName success:(void (^)(void))success + failure:(void (^)(NSError *err))failure; + +@end diff --git a/GIGA/Common/GiGaFileManager/GiGaFileNanager.m b/GIGA/Common/GiGaFileManager/GiGaFileNanager.m new file mode 100644 index 0000000..b079a35 --- /dev/null +++ b/GIGA/Common/GiGaFileManager/GiGaFileNanager.m @@ -0,0 +1,68 @@ +// +// GiGaFileNanager.m +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GiGaFileNanager.h" + +@implementation GiGaFileNanager + ++ (GiGaFileNanager *)shareInstance +{ + static GiGaFileNanager *manager = nil; + static dispatch_once_t once; + dispatch_once(&once, ^{ + manager = [[self alloc] init]; + }); + + return manager; +} + +- (BOOL)isFileExistWithFilePath:(NSString *)filePath +{ + NSFileManager *fileManager = [NSFileManager defaultManager]; + BOOL isDirectory = FALSE; + return [fileManager fileExistsAtPath:filePath isDirectory:&isDirectory]; +} + +-(NSString *)getFilePathWithImageName:(NSString *)imageName{ + + if (imageName) { + + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES); + NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:imageName]; + return filePath; + } + return nil; +} + +-(void)removeItemAtPath:(NSString *)filePath{ + NSFileManager *filManager = [NSFileManager defaultManager]; + [filManager removeItemAtPath:filePath error:nil]; +} + +- (void)saveAdImageWithUrl:(NSString *)imageUrl imageName:(NSString *)imageName success:(void (^)(void))success + failure:(void (^)(NSError *err))failure{ + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]; + + UIImage *image = [UIImage imageWithData:data]; + NSString *filePath = [self getFilePathWithImageName:imageName]; // 保存文件的名称 + if ([UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES]) { + //NSLog(@"保存成功"); + + success(); + + }else{ + //NSLog(@"保存失败"); + NSError *err; + failure(err); + } }); +} + + +@end diff --git a/GIGA/Common/GiGaUserDB/GiGaUserDefault.h b/GIGA/Common/GiGaUserDB/GiGaUserDefault.h index 8aa16da..1d8ce43 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserDefault.h +++ b/GIGA/Common/GiGaUserDB/GiGaUserDefault.h @@ -15,8 +15,9 @@ +(void)saveUserId:(NSString *)userId; +(NSString *)getCurentUserId; -+(void)removeUserId; ++(void)removeUserId;//退出登录 +(BOOL)isUserLogin; + /** 保存用户表版本号 */ diff --git a/GIGA/Common/GiGaUserDB/GiGaUserDefault.m b/GIGA/Common/GiGaUserDB/GiGaUserDefault.m index 550e555..15e9993 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserDefault.m +++ b/GIGA/Common/GiGaUserDB/GiGaUserDefault.m @@ -30,6 +30,7 @@ NSString *const kShowAppGuard = @"ShowAppGuard"; +(void)removeUserId{ UD_REMOVE_KEY(GIGADEFAULTKEY_USERID); + } +(BOOL)isUserLogin{ diff --git a/GIGA/Config/GIGA.h b/GIGA/Config/GIGA.h index 47b0988..3787bb2 100644 --- a/GIGA/Config/GIGA.h +++ b/GIGA/Config/GIGA.h @@ -33,8 +33,9 @@ UD_SYNC // MAKR: Noti Names #define USER_GUARD_DISSMISS @"userGaurdDissmiss" #define APP_GUARD_DISSMISS @"APPGaurdDissmiss" - - +//adView +//#define APP_START_ADVIEW_PUSH @"APPStartAdviewpush" +#define APP_PUSHTO_DETAILVIEW @"appPushToDetailAdView" #define GIGARGB(R,G,B,A) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:A] @@ -65,5 +66,6 @@ alpha:((float)(rgbValue & 0xFF))/255.0] #define textFontWeightSize(X,W) [UIFont systemFontOfSize:X *([UIScreen mainScreen].bounds.size.width / 320.0) weight:W] +#define GIGA_ShowToast(__toast__) [self.view makeToast:(__toast__) duration:1.5 position:CSToastPositionCenter]; #endif /* GIGA_h */ diff --git a/GIGA/GIGA.entitlements b/GIGA/GIGA.entitlements new file mode 100644 index 0000000..903def2 --- /dev/null +++ b/GIGA/GIGA.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/GIGA/Info.plist b/GIGA/Info.plist index ab33e25..6183edb 100644 --- a/GIGA/Info.plist +++ b/GIGA/Info.plist @@ -2,11 +2,6 @@ - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -27,6 +22,15 @@ 1 LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UIBackgroundModes + + remote-notification + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.h b/GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.h new file mode 100644 index 0000000..70446e4 --- /dev/null +++ b/GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.h @@ -0,0 +1,13 @@ +// +// GiGaAdDetailViewController.h +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +@interface GiGaAdDetailViewController : UIViewController + +@end diff --git a/GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.m b/GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.m new file mode 100644 index 0000000..a4f79c4 --- /dev/null +++ b/GIGA/Modules/AppAD/GiGaAdDetailViewController/GiGaAdDetailViewController.m @@ -0,0 +1,38 @@ +// +// GiGaAdDetailViewController.m +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GiGaAdDetailViewController.h" + +@interface GiGaAdDetailViewController () + +@end + +@implementation GiGaAdDetailViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = @"广告详情"; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.h b/GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.h new file mode 100644 index 0000000..e082018 --- /dev/null +++ b/GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.h @@ -0,0 +1,28 @@ +// +// GiGaStartAdView.h +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +static NSString *const kAdImageNamekey = @"adImageName"; +static NSString *const kAdUrlKey = @"adUrl"; + +@interface GiGaStartAdView : UIView + +@property (nonatomic,strong) UIImageView *adView; +/** + 显示启动页广告 + */ +-(void)show; + +/** + 图片路径 + */ +@property(nonatomic,copy) NSString *imagePath; + + +@end diff --git a/GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.m b/GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.m new file mode 100644 index 0000000..3df7e21 --- /dev/null +++ b/GIGA/Modules/AppAD/GiGaStartAdView/GiGaStartAdView.m @@ -0,0 +1,151 @@ +// +// GiGaStartAdView.m +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GiGaStartAdView.h" +#import "GiGaFileNanager.h" +#import "UIImageView+WebCache.h" + +@interface GiGaStartAdView() + +@property (nonatomic,strong) UIButton *countBtn; +@property (nonatomic,strong) NSTimer *countTimer; +@property (nonatomic,assign) int count; + + +@end +static int const showTime = 12; + +@implementation GiGaStartAdView + +- (NSTimer *)countTimer{ + + if (!_countTimer) { + + _countTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES]; + + } + return _countTimer; +} + +- (instancetype)initWithFrame:(CGRect)frame{ + if (self = [super initWithFrame:frame]) { + [self initUIWithFrame:frame]; + } + return self; + +} +-(void)initUIWithFrame:(CGRect)frame{ + + self.backgroundColor = [UIColor whiteColor]; + _adView = [[UIImageView alloc] initWithFrame:frame]; + _adView.userInteractionEnabled = YES; + _adView.contentMode = UIViewContentModeScaleAspectFill; + _adView.clipsToBounds = YES; + //广告点击手势 + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoAd)]; + [_adView addGestureRecognizer:tap]; + CGFloat btnW = 60; + CGFloat btnH = 30; + _countBtn = [[UIButton alloc] initWithFrame:CGRectMake(KMainW - btnW - 24, btnH, btnW, btnH)]; + [_countBtn addTarget:self action:@selector(removeAdView) forControlEvents:UIControlEventTouchUpInside]; + [_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",showTime] forState:UIControlStateNormal]; + _countBtn.titleLabel.font = [UIFont systemFontOfSize:15]; + [_countBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + _countBtn.backgroundColor = GIGARGB(38, 38, 38, 0.6) ; + _countBtn.layer.masksToBounds = YES; + _countBtn.layer.cornerRadius = 4; + [self addSubview:_adView]; + [self addSubview:_countBtn]; + +} + +-(void)removeAdView{ + + [self.countTimer invalidate]; + self.countTimer = nil; + [UIView animateWithDuration:0.3f animations:^{ + self.alpha = 0.f; + } completion:^(BOOL finished) { + [self removeFromSuperview]; + }]; +} + +-(void)gotoAd{ + + [self removeAdView]; + NC_POST_NAME_OBJECT(APP_PUSHTO_DETAILVIEW, nil); + +} + +-(void)countDown{ + + _count --; + [_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",_count] forState:UIControlStateNormal]; + if (_count == 0) { + [self removeAdView]; + } +} + + +-(void)show{ + + [self loadImage]; + UIWindow *window = [UIApplication sharedApplication].keyWindow; + [window addSubview:self]; + //[self startTimer]; + //GCD 备用 + [self gcdStartCount]; + +} + +-(void)loadImage{ + + NSArray *imageArray = @[ @"https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a4b3d7085dee3d6d2293d48b252b5910/0e2442a7d933c89524cd5cd4d51373f0830200ea.jpg", @"https://ss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a41eb338dd33c895a62bcb3bb72e47c2/5fdf8db1cb134954a2192ccb524e9258d1094a1e.jpg" ]; + NSString *imageUrl = imageArray[arc4random() % imageArray.count]; // 获取图片名:43-130P5122Z60-50.jpg + + [_adView sd_setImageWithURL:[NSURL URLWithString:imageUrl] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + NSLog(@"%@",error); + + }]; + + +} + +-(void)startTimer{ + _count = showTime; + [[NSRunLoop mainRunLoop] addTimer:self.countTimer forMode:NSRunLoopCommonModes]; + +} +-(void)gcdStartCount{ + + weakify(self); + __block int timeout = showTime + 1; //倒计时时间 + 1 + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue); dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0 * NSEC_PER_SEC, 0); + //每秒执行 + dispatch_source_set_event_handler(_timer, ^{ if(timeout <= 0){ //倒计时结束,关闭 + dispatch_source_cancel(_timer); + dispatch_async(dispatch_get_main_queue(), ^{ + + [weakSelf removeAdView]; + + }); + + }else{ dispatch_async(dispatch_get_main_queue(), ^{ + + [weakSelf.countBtn setTitle:[NSString stringWithFormat:@"跳过%d",timeout] forState:UIControlStateNormal]; + + }); + timeout--; + + } }); + dispatch_resume(_timer); +} + + + +@end diff --git a/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m b/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m index a69b579..9fb2a7a 100644 --- a/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m +++ b/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m @@ -10,7 +10,7 @@ #import "UINavigationBar+Custom.h" #import "PassWordResetVC.h" #import "GiGaRegistViewController.h" - +#import "GiGaUserDefault.h" @interface GiGaUserLoginVC () @property (weak, nonatomic) IBOutlet UIImageView *userImagView; @property (weak, nonatomic) IBOutlet UITextField *acountTextField; @@ -32,6 +32,8 @@ [self setUpX]; [self textFieldUI]; [self.registBtn addTarget:self action:@selector(registBtnAction) forControlEvents:UIControlEventTouchUpInside]; + [self.loginBtn addTarget:self action:@selector(loginBtnAction:) forControlEvents:UIControlEventTouchUpInside]; + } @@ -98,6 +100,7 @@ } +#pragma mark - 去注册 -(void)registBtnAction{ GiGaRegistViewController *registVC = [[GiGaRegistViewController alloc] init]; @@ -106,5 +109,10 @@ } +#pragma mark - 登录 +-(void)loginBtnAction:(UIButton *)btn{ + [GiGaUserDefault saveUserId:@"123"]; + +} @end diff --git a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m index f551f04..c4f93ec 100644 --- a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m +++ b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m @@ -12,6 +12,9 @@ #import "UserGuardViewController.h" #import "GiGaUserDefault.h" #import "GiGaAppGaurdVC.h" +#import "UIView+Toast.h" +#import "GiGaMeViewController.h" +#import "GiGaAdDetailViewController.h" @interface GiGaMaskTaskViewController () @property(nonatomic,strong)MaskViewBootomWaringView *waringView; @@ -24,7 +27,6 @@ // Do any additional setup after loading the view. [self setUpNav]; [self addNotify]; - BOOL canshowGaurd = [GiGaUserDefault isShowedGaurd]; if (!canshowGaurd) { NSLog(@"%d",(int)canshowGaurd ); @@ -46,8 +48,16 @@ NC_ADD_TARGET_NAME_OBJECT(self, @selector(guardViewDissmiss), USER_GUARD_DISSMISS, nil) ; NC_ADD_TARGET_NAME_OBJECT(self, @selector(appGauardViewDissmiss),APP_GUARD_DISSMISS, nil) ; + NC_ADD_TARGET_NAME_OBJECT(self, @selector(pushToAppAdDetailView),APP_PUSHTO_DETAILVIEW, nil) ; } +#pragma mark 广告详情 +-(void)pushToAppAdDetailView{ + + GiGaAdDetailViewController *detailVC=[[GiGaAdDetailViewController alloc] init]; + [self.navigationController pushViewController:detailVC animated:YES]; + +} #pragma mark 新手引导消失 -(void)guardViewDissmiss{ [self showWaringView]; @@ -65,6 +75,8 @@ NC_REMOVE_NAME(self, USER_GUARD_DISSMISS, nil); NC_REMOVE_NAME(self, APP_GUARD_DISSMISS, nil); + NC_REMOVE_NAME(self, APP_PUSHTO_DETAILVIEW, nil); + } #pragma mark 新手引导 @@ -106,11 +118,16 @@ #pragma mark 消息 action -(void)leftBtnAction{ - - GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init]; - GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC]; - [self presentViewController:baseNav animated:YES completion:nil]; - + BOOL isUserLogin = [GiGaUserDefault isUserLogin]; + if (isUserLogin) { + GIGA_ShowToast(@"userLogin!"); + + + }else{ + GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init]; + GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC]; + [self presentViewController:baseNav animated:YES completion:nil]; + } } #pragma mark 个人中心 action diff --git a/GIGA/Modules/Mask/View/MaskViewBootomWaringView.h b/GIGA/Modules/Mask/View/MaskViewBootomWaringView.h index e9666f5..2d5dec9 100644 --- a/GIGA/Modules/Mask/View/MaskViewBootomWaringView.h +++ b/GIGA/Modules/Mask/View/MaskViewBootomWaringView.h @@ -9,7 +9,7 @@ #import #import "GiGaBlockButton.h" @interface MaskViewBootomWaringView : UIView + @property(nonatomic,strong) GiGaBlockButton *dismissBtn; - @end diff --git a/GIGA/Modules/Me/Controller/GiGaMeViewController.h b/GIGA/Modules/Me/Controller/GiGaMeViewController.h new file mode 100644 index 0000000..deda6ca --- /dev/null +++ b/GIGA/Modules/Me/Controller/GiGaMeViewController.h @@ -0,0 +1,13 @@ +// +// GiGaMeViewController.h +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +@interface GiGaMeViewController : UIViewController + +@end diff --git a/GIGA/Modules/Me/Controller/GiGaMeViewController.m b/GIGA/Modules/Me/Controller/GiGaMeViewController.m new file mode 100644 index 0000000..d811e88 --- /dev/null +++ b/GIGA/Modules/Me/Controller/GiGaMeViewController.m @@ -0,0 +1,37 @@ +// +// GiGaMeViewController.m +// GIGA +// +// Created by lianxiang on 2018/8/22. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GiGaMeViewController.h" + +@interface GiGaMeViewController () + +@end + +@implementation GiGaMeViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/GIGA/ViewController.m b/GIGA/ViewController.m index 8b40b70..6d15f4a 100644 --- a/GIGA/ViewController.m +++ b/GIGA/ViewController.m @@ -7,7 +7,7 @@ // #import "ViewController.h" -#import "AppDelegate.h" + @interface ViewController () @end @@ -17,7 +17,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - + self.view.backgroundColor = [UIColor purpleColor]; // Do any additional setup after loading the view, typically from a nib. }