add jpush 启动广告页

This commit is contained in:
lianxiang 2018-08-22 17:53:17 +08:00
parent b7bedad48c
commit 3b8f57d02f
24 changed files with 545 additions and 34 deletions

View File

@ -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 = "<group>"; };
8349585A212511040064DB6C /* AppDelegate+ThirdParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+ThirdParty.h"; sourceTree = "<group>"; };
8349585B212511040064DB6C /* AppDelegate+ThirdParty.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+ThirdParty.m"; sourceTree = "<group>"; };
835060A0212D1225007E6220 /* GiGaMeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMeViewController.h; sourceTree = "<group>"; };
835060A1212D1225007E6220 /* GiGaMeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMeViewController.m; sourceTree = "<group>"; };
835060A3212D2321007E6220 /* GIGA.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GIGA.entitlements; sourceTree = "<group>"; };
835060A7212D38EE007E6220 /* GiGaStartAdView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaStartAdView.h; sourceTree = "<group>"; };
835060A8212D38EE007E6220 /* GiGaStartAdView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaStartAdView.m; sourceTree = "<group>"; };
835060AB212D4D0C007E6220 /* GiGaFileNanager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFileNanager.h; sourceTree = "<group>"; };
835060AC212D4D0C007E6220 /* GiGaFileNanager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFileNanager.m; sourceTree = "<group>"; };
835060B1212D54C2007E6220 /* GiGaAdDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaAdDetailViewController.h; sourceTree = "<group>"; };
835060B2212D54C2007E6220 /* GiGaAdDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaAdDetailViewController.m; sourceTree = "<group>"; };
8357ADC32123BEBD000816F2 /* GiGaUser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaUser.h; sourceTree = "<group>"; };
8357ADC42123BEBD000816F2 /* GiGaUser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaUser.m; sourceTree = "<group>"; };
8357ADC72123BFCA000816F2 /* GiGaUserManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaUserManager.h; sourceTree = "<group>"; };
@ -229,6 +242,42 @@
path = Source;
sourceTree = "<group>";
};
835060A6212D38BC007E6220 /* GiGaStartAdView */ = {
isa = PBXGroup;
children = (
835060A7212D38EE007E6220 /* GiGaStartAdView.h */,
835060A8212D38EE007E6220 /* GiGaStartAdView.m */,
);
path = GiGaStartAdView;
sourceTree = "<group>";
};
835060AA212D4C0F007E6220 /* GiGaFileManager */ = {
isa = PBXGroup;
children = (
835060AB212D4D0C007E6220 /* GiGaFileNanager.h */,
835060AC212D4D0C007E6220 /* GiGaFileNanager.m */,
);
path = GiGaFileManager;
sourceTree = "<group>";
};
835060AE212D5423007E6220 /* AppAD */ = {
isa = PBXGroup;
children = (
835060AF212D5467007E6220 /* GiGaAdDetailViewController */,
835060A6212D38BC007E6220 /* GiGaStartAdView */,
);
path = AppAD;
sourceTree = "<group>";
};
835060AF212D5467007E6220 /* GiGaAdDetailViewController */ = {
isa = PBXGroup;
children = (
835060B1212D54C2007E6220 /* GiGaAdDetailViewController.h */,
835060B2212D54C2007E6220 /* GiGaAdDetailViewController.m */,
);
path = GiGaAdDetailViewController;
sourceTree = "<group>";
};
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 = "<group>";
@ -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";
};

View File

@ -15,6 +15,8 @@
//v1.0
- (void)setupRootVC;
/**
广
*/
-(void)creatAdView;
@end

View File

@ -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

View File

@ -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); // BadgeSoundAlert
completionHandler(UNNotificationPresentationOptionAlert|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionBadge); // BadgeSoundAlert
}
@ -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];
}

View File

@ -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.
}

View File

@ -4,6 +4,14 @@
"idiom" : "universal",
"filename" : "maske_dismiss_waring.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {

View File

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -13,7 +17,7 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.40468725620000001" green="1" blue="0.9282041969" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>

View File

@ -0,0 +1,20 @@
//
// GiGaFileNanager.h
// GIGA
//
// Created by lianxiang on 2018/8/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@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

View File

@ -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

View File

@ -15,8 +15,9 @@
+(void)saveUserId:(NSString *)userId;
+(NSString *)getCurentUserId;
+(void)removeUserId;
+(void)removeUserId;//退出登录
+(BOOL)isUserLogin;
/**
*/

View File

@ -30,6 +30,7 @@ NSString *const kShowAppGuard = @"ShowAppGuard";
+(void)removeUserId{
UD_REMOVE_KEY(GIGADEFAULTKEY_USERID);
}
+(BOOL)isUserLogin{

View File

@ -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 */

8
GIGA/GIGA.entitlements Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>

View File

@ -2,11 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
@ -27,6 +22,15 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>

View File

@ -0,0 +1,13 @@
//
// GiGaAdDetailViewController.h
// GIGA
//
// Created by lianxiang on 2018/8/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GiGaAdDetailViewController : UIViewController
@end

View File

@ -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

View File

@ -0,0 +1,28 @@
//
// GiGaStartAdView.h
// GIGA
//
// Created by lianxiang on 2018/8/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "GiGaBlockButton.h"
@interface MaskViewBootomWaringView : UIView
@property(nonatomic,strong) GiGaBlockButton *dismissBtn;
@end

View File

@ -0,0 +1,13 @@
//
// GiGaMeViewController.h
// GIGA
//
// Created by lianxiang on 2018/8/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GiGaMeViewController : UIViewController
@end

View File

@ -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

View File

@ -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.
}