Quellcode durchsuchen

海外广告sdk(旧的UI登录界面) commit

xieguangming vor 3 Jahren
Ursprung
Commit
ae67bb31e6

+ 7 - 1
NatureSDK/XenonDemo/AppDelegate.m

@@ -64,7 +64,12 @@
     
     //1. Adjust SDK init.
     NSString *appToken = [NSBundle mainBundle].infoDictionary[@"kAppToken"];
+    
+#ifdef DEBUG
     NSString *environment = ADJEnvironmentSandbox;
+#else
+    NSString *environment = ADJEnvironmentProduction;
+#endif
     //开发:ADJEnvironmentSandbox,  线上:ADJEnvironmentProduction
     ADJConfig *adjustConfig = [ADJConfig configWithAppToken:appToken environment:environment];
     [adjustConfig setLogLevel:ADJLogLevelVerbose];
@@ -79,7 +84,8 @@
     
     //3.Facebook SDK init
     [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
-    
+    //[FBSDKSettings setAdvertiserTrackingEnabled:YES];
+    [FBSDKSettings setAutoLogAppEventsEnabled:YES];
     
     return YES;
 }

+ 16 - 0
NatureSDK/XenonSDK.xcodeproj/project.pbxproj

@@ -28,6 +28,8 @@
 		077543E02608418200262137 /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 077543DF2608418200262137 /* iAd.framework */; };
 		077543E22608419900262137 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 077543E12608419900262137 /* CoreTelephony.framework */; };
 		077543E4260841A700262137 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 077543E3260841A700262137 /* StoreKit.framework */; };
+		077715EE266DF037008860FB /* KDIAPManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 077715EC266DF037008860FB /* KDIAPManager.h */; };
+		077715EF266DF037008860FB /* KDIAPManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 077715ED266DF037008860FB /* KDIAPManager.m */; };
 		077DA2C52626EF95001465DF /* FqAdmobNativeBanner.xib in Resources */ = {isa = PBXBuildFile; fileRef = 076913BA260B5AA300E1BB6F /* FqAdmobNativeBanner.xib */; };
 		077FCFBC2611CA26005DF86B /* FqIronsourceInterstitial.h in Headers */ = {isa = PBXBuildFile; fileRef = 077FCFBA2611CA26005DF86B /* FqIronsourceInterstitial.h */; };
 		077FCFBD2611CA26005DF86B /* FqIronsourceInterstitial.m in Sources */ = {isa = PBXBuildFile; fileRef = 077FCFBB2611CA26005DF86B /* FqIronsourceInterstitial.m */; };
@@ -191,6 +193,8 @@
 		077543DF2608418200262137 /* iAd.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = iAd.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks/iAd.framework; sourceTree = DEVELOPER_DIR; };
 		077543E12608419900262137 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreTelephony.framework; sourceTree = DEVELOPER_DIR; };
 		077543E3260841A700262137 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks/StoreKit.framework; sourceTree = DEVELOPER_DIR; };
+		077715EC266DF037008860FB /* KDIAPManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KDIAPManager.h; sourceTree = "<group>"; };
+		077715ED266DF037008860FB /* KDIAPManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KDIAPManager.m; sourceTree = "<group>"; };
 		077FCFBA2611CA26005DF86B /* FqIronsourceInterstitial.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FqIronsourceInterstitial.h; sourceTree = "<group>"; };
 		077FCFBB2611CA26005DF86B /* FqIronsourceInterstitial.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FqIronsourceInterstitial.m; sourceTree = "<group>"; };
 		0788ECA7260CA48500C2FFCD /* FqIronsourceOfferWall.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FqIronsourceOfferWall.h; sourceTree = "<group>"; };
@@ -407,6 +411,15 @@
 			path = Ironsource;
 			sourceTree = "<group>";
 		};
+		077715EB266DF037008860FB /* KDIAPManager */ = {
+			isa = PBXGroup;
+			children = (
+				077715EC266DF037008860FB /* KDIAPManager.h */,
+				077715ED266DF037008860FB /* KDIAPManager.m */,
+			);
+			path = KDIAPManager;
+			sourceTree = "<group>";
+		};
 		0788ECAD260CB87000C2FFCD /* AdBase */ = {
 			isa = PBXGroup;
 			children = (
@@ -430,6 +443,7 @@
 		0C389564229D483E0087AC2C /* XenonSDK */ = {
 			isa = PBXGroup;
 			children = (
+				077715EB266DF037008860FB /* KDIAPManager */,
 				0C6B9818229E7A6E00A970D3 /* XenonThemes */,
 				0C6B97C6229E77E600A970D3 /* Classes */,
 				0CEBEF1D229E277900B93CB7 /* XenonThirdParty */,
@@ -696,6 +710,7 @@
 				0770654226087F3500015DE4 /* FqIronsourceBanner.h in Headers */,
 				0C2BA8AC229FA7F000002F2D /* XSDataCenter.h in Headers */,
 				0C2BA898229F75D800002F2D /* UserRestPasswordViewController.h in Headers */,
+				077715EE266DF037008860FB /* KDIAPManager.h in Headers */,
 				0C389757229D55530087AC2C /* XSNetwork.h in Headers */,
 				0C2BA8B7229FCBCB00002F2D /* TalkingDataGA.h in Headers */,
 				0C2BA8A0229F8DBA00002F2D /* UserLoginFastViewController.h in Headers */,
@@ -958,6 +973,7 @@
 				0C2BA8A1229F8DBA00002F2D /* UserLoginFastViewController.m in Sources */,
 				0C38975E229D61F60087AC2C /* XSUtils.m in Sources */,
 				0C6B97CA229E77FD00A970D3 /* RootViewController.m in Sources */,
+				077715EF266DF037008860FB /* KDIAPManager.m in Sources */,
 				076913C7260B5AA300E1BB6F /* FqAdmobNativeBanner.m in Sources */,
 				0770653F26087F3500015DE4 /* GMAdManager.m in Sources */,
 				0C2BA8AD229FA7F000002F2D /* XSDataCenter.m in Sources */,

BIN
NatureSDK/XenonSDK.xcworkspace/xcuserdata/fq.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 208
NatureSDK/XenonSDK.xcworkspace/xcuserdata/fq.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -16,86 +16,6 @@
             stopOnStyle = "0">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "BB35724F-D00D-4AD8-A19E-5227D6A6C91B"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "959"
-            endingLineNumber = "959"
-            landmarkName = "-xautoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "86053D4B-BE03-4BED-8C3C-430D0E0B6073"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "990"
-            endingLineNumber = "990"
-            landmarkName = "-xautoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "D8CF18BE-F731-4B11-B474-4CA14D910A4D"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "955"
-            endingLineNumber = "955"
-            landmarkName = "-xautoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "718532F6-DE5A-44C2-B5ED-1A4FB35C5391"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "966"
-            endingLineNumber = "966"
-            landmarkName = "-xautoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "C9475802-86F9-478C-8EC1-A1C130A2B1E6"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "976"
-            endingLineNumber = "976"
-            landmarkName = "-xautoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -128,22 +48,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "BD3067B5-0B51-488A-A5EE-CA10FB392CEA"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "662"
-            endingLineNumber = "662"
-            landmarkName = "-setUser:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -192,117 +96,5 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "72A4168B-3576-49EE-B395-85A1EC214980"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1001"
-            endingLineNumber = "1001"
-            landmarkName = "-hAutoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "E2BABFF1-30EF-4592-B5D9-C1B4BF4A7686"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1007"
-            endingLineNumber = "1007"
-            landmarkName = "-hAutoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "EE299EE0-F39E-4B48-8267-D835169A189A"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1015"
-            endingLineNumber = "1015"
-            landmarkName = "-hAutoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "1E659C80-6EFB-4B0E-8BB9-51E8366CFFA6"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1024"
-            endingLineNumber = "1024"
-            landmarkName = "-hAutoWithComplete:"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "1E659C80-6EFB-4B0E-8BB9-51E8366CFFA6 - 586d65fdc16b784a"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "-[XenonSDK hAutoWithComplete:]"
-                  moduleName = "XenonSDK"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/fq/Documents/ios-adv/FqAdSdk/NatureSDK/XenonSDK/XenonSDK.m"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "1025"
-                  endingLineNumber = "1025"
-                  offsetFromSymbolStart = "596">
-               </Location>
-               <Location
-                  uuid = "1E659C80-6EFB-4B0E-8BB9-51E8366CFFA6 - 320ff01d05e5d442"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "__30-[XenonSDK hAutoWithComplete:]_block_invoke.547"
-                  moduleName = "XenonSDK"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/fq/Documents/ios-adv/FqAdSdk/NatureSDK/XenonSDK/XenonSDK.m"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "1026"
-                  endingLineNumber = "1026"
-                  offsetFromSymbolStart = "88">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "941A8144-0FF5-4CF9-BD8E-234EB57C3252"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "XenonSDK/XenonSDK.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1037"
-            endingLineNumber = "1037"
-            landmarkName = "-hAutoWithComplete:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 42 - 0
NatureSDK/XenonSDK/KDIAPManager/KDIAPManager.h

@@ -0,0 +1,42 @@
+//
+//  KDIAPManager.h
+//  KDChat
+//
+//  Created by JYJ on 2019/6/14.
+//  Copyright © 2019 dcjf. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+typedef NS_ENUM(NSUInteger,IAPResultType) {
+    IAPResultSuccess = 0,       // 购买成功
+    IAPResultFailed = 1,        // 购买失败
+    IAPResultCancle = 2,        // 取消购买
+    IAPResultVerFailed = 3,     // 订单校验失败
+    IAPResultVerSuccess = 4,    // 订单校验成功
+    IAPResultNotArrow = 5,      // 不允许内购
+    IAPResultIDError = 6,       // 项目ID错误
+};
+
+
+
+typedef void(^IAPCompletionHandle)(IAPResultType type, NSData *data);
+
+@interface KDIAPManager : NSObject
+
++ (instancetype)shareIAPManager;
+
+/** 检测客户端与服务器漏单情况处理*/
++ (void)checkOrderStatus;
+
+/**
+ 开启内购
+ 
+ @param productID 内购项目的产品ID
+ @param handle 内购的结果回调
+ */
+- (void)startIAPWithOrderId:(NSString *)orderId productID:(NSString *)productID completeHandle: (IAPCompletionHandle)handle;
+
+@end
+

+ 379 - 0
NatureSDK/XenonSDK/KDIAPManager/KDIAPManager.m

@@ -0,0 +1,379 @@
+//
+//  KDIAPManager.m
+//  KDChat
+//
+//  Created by JYJ on 2019/6/14.
+//  Copyright © 2019 dcjf. All rights reserved.
+//
+
+#import "KDIAPManager.h"
+#import <StoreKit/StoreKit.h>
+//#import "KDMainPresenter.h"
+#import "XSNetwork.h"
+#import <Adjust/Adjust.h>
+
+@interface KDIAPManager() <SKPaymentTransactionObserver,SKProductsRequestDelegate> {
+    IAPCompletionHandle _handle;
+}
+
+@property (nonatomic, strong) NSString* productId;
+
+@property (nonatomic, strong) NSString* orderId;
+
+/** presenter */
+//请求网络的.
+//@property (nonatomic, strong) KDMainPresenter *presenter;
+
+@end
+
+
+@implementation KDIAPManager
+
+/**
+ 单例模式
+ 
+ @return HZIAPManager
+ */
++ (instancetype)shareIAPManager {
+    static KDIAPManager *IAPManager = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        IAPManager = [[KDIAPManager alloc] init];
+    });
+    return IAPManager;
+}
+
+- (instancetype)init {
+    if (self = [super init]) {
+        [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
+    }
+    return self;
+}
+- (void)dealloc {
+    [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
+}
+
+#pragma mark -- Method
+/** 检测客户端与服务器漏单情况处理*/
++ (void)checkOrderStatus {
+    NSDictionary *orderInfo = [KDIAPManager getReceiptData];
+    
+    if (orderInfo != nil) {
+        NSString *orderId = orderInfo[@"orderId"];
+        id receipt = orderInfo[@"receipt"];
+        [[KDIAPManager shareIAPManager] verifyPurchaseForServiceWithOrderId:orderId receipt:receipt];
+    }
+}
+
+#pragma mark -- 结束上次未完成的交易
+- (void)removeAllUncompleteTransactionsBeforeNewPurchase {
+    NSArray* transactions = [SKPaymentQueue defaultQueue].transactions;
+    if (transactions.count >= 1) {
+        for (SKPaymentTransaction* transaction in transactions) {
+            if (transaction.transactionState == SKPaymentTransactionStatePurchased ||
+                transaction.transactionState == SKPaymentTransactionStateRestored) {
+                [[SKPaymentQueue defaultQueue]finishTransaction:transaction];
+            }
+        }
+    } else {
+        NSLog(@"没有历史未消耗订单");
+    }
+}
+
+- (void)startIAPWithOrderId:(NSString *)orderId  productID:(NSString *)productID completeHandle: (IAPCompletionHandle)handle {
+    _handle = handle;
+    if(productID && productID.length > 0) {
+        if ([SKPaymentQueue canMakePayments]) {
+            [self removeAllUncompleteTransactionsBeforeNewPurchase];
+            self.orderId = orderId;
+            // 允许内购
+            self.productId = productID;
+            NSSet *set = [NSSet setWithObjects:productID, nil];
+            SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:set];
+            request.delegate = self;
+            // 获取内购项目信息
+            [request start];
+        } else {
+            // 不允许内购
+            [self handleActionWithType:IAPResultNotArrow data:nil];
+        }
+    } else {
+        NSLog(@"内购项目ID错误");
+        [XSNetwork errorWithCode:-3 message:@"产品暂时不可用,请检查苹果后台"];
+        [self handleActionWithType:IAPResultIDError data:nil];
+    }
+    
+}
+- (void)handleActionWithType:(IAPResultType)type data:(NSData *)data{
+    switch (type) {
+        case IAPResultSuccess:
+            NSLog(@"购买成功");
+            break;
+        case IAPResultFailed:
+            NSLog(@"购买失败");
+            break;
+        case IAPResultCancle:
+            NSLog(@"用户取消购买");
+            break;
+        case IAPResultVerFailed:
+            NSLog(@"订单校验失败");
+            break;
+        case IAPResultVerSuccess:
+            NSLog(@"订单校验成功");
+            break;
+        case IAPResultNotArrow:
+            NSLog(@"不允许程序内付费");
+            break;
+        default:
+            break;
+    }
+    if(_handle){
+        _handle(type, data);
+    }
+}
+
+#pragma mark --  SKProductsRequestDelegate
+/**
+ 收到产品信息的回调
+ 
+ @param request  请求的信息
+ @param response 返回的产品信息
+ */
+- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
+    
+    // 商品所在数组
+    NSArray *productArr = response.products;
+    if (productArr.count > 0) {
+//        SKProduct *product = nil;
+        for (SKProduct *product in productArr) {
+            if ([product.productIdentifier isEqualToString:self.productId]) {
+//                product = p;
+                SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
+                payment.quantity = 1;
+//                payment.applicationUsername
+                
+//                payment.applicationUsername = _orderId;
+                // 发起内购
+                [[SKPaymentQueue defaultQueue] addPayment:payment];
+                break;
+            }
+        }
+    } else {
+        [self handleActionWithType:IAPResultIDError data:nil];
+    }
+    
+    
+//    if ([response.invalidProductIdentifiers containsObject:self.productId]) {
+//        self.callback(nil, [XSNetwork errorWithCode:-3 message:@"产品暂时不可用,请检查苹果后台"]);
+//        return;
+//    }
+//
+//    for (SKProduct* product in response.products) {
+//
+//        SKMutablePayment* payment = [SKMutablePayment paymentWithProduct:product];;
+//        payment.applicationUsername = self.orderId;
+//        [SKPaymentQueue.defaultQueue addPayment:payment];
+//    }
+    
+    
+}
+
+
+#pragma mark --  SKPaymentTransactionObserver
+- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
+    // 获取结果
+    // 验证成功与否都注销交易,否则会出现虚假凭证信息一直验证不通过,每次进程序都得输入苹果账号
+    for (SKPaymentTransaction *trans in transactions) {
+        switch (trans.transactionState) {
+            case SKPaymentTransactionStatePurchasing:
+                NSLog(@"商品添加进列表");
+                break;
+            case SKPaymentTransactionStatePurchased:
+            {
+                NSLog(@"交易完成");
+                [self completeTransaction:trans];
+                [[SKPaymentQueue defaultQueue] finishTransaction:trans];
+                //adjust统计内购支付事件
+                NSString *kRechargeEventToken = [NSBundle mainBundle].infoDictionary[@"kRechargeEventToken"];
+                ADJEvent *event = [ADJEvent eventWithEventToken:kRechargeEventToken];
+                //[event setRevenue:1.0 currency:@"EUR"];
+                [event setTransactionId:trans.transactionIdentifier]; //避免重复
+                [Adjust trackEvent:event];
+            }
+                break;
+            case SKPaymentTransactionStateFailed:
+                NSLog(@"交易失败");
+                [self failedTransaction:trans];
+                [[SKPaymentQueue defaultQueue] finishTransaction:trans];
+                break;
+            case SKPaymentTransactionStateRestored:
+                NSLog(@"已经购买过商品");
+                [[SKPaymentQueue defaultQueue] finishTransaction:trans]; //消耗型商品不用写
+                break;
+            case SKPaymentTransactionStateDeferred:
+                
+                break;
+            default:
+                break;
+        }
+    }
+}
+/**
+ 内购完成
+ 
+ @param transaction 内购项目体
+ */
+- (void)completeTransaction:(SKPaymentTransaction *)transaction {
+    NSString *productIdentifier = transaction.payment.productIdentifier;
+    NSURL *recepitURL = [[NSBundle mainBundle] appStoreReceiptURL];
+    NSData *data = [NSData dataWithContentsOfURL:recepitURL];
+    id  receiptString =  [data base64EncodedStringWithOptions:0];
+    
+    if ([productIdentifier length] > 0 && data) {
+        
+        if (receiptString && self.orderId.length > 0) {
+            //1.保存订单号和报文到本地.
+            [self saveReceiptData:@{@"receipt":receiptString,
+                                    @"orderId":self.orderId ?:@""}];
+            
+            //2.向自己的服务器验证购买凭证.
+            [self verifyPurchaseForServiceWithOrderId:self.orderId
+                                              receipt:receiptString];
+        }
+        
+    } else {
+        [self handleActionWithType:IAPResultVerFailed data:nil];
+    }
+    
+    
+//    // 自己向苹果发送验证
+//    [self verifyPurchaseWithPaymentTransaction:transaction isTestServer:NO];
+}
+
+
+
+///服务器验证购买凭证.
+- (void)verifyPurchaseForServiceWithOrderId:(NSString *)orderId
+                                    receipt:(id)receiptString {
+    if (orderId == nil && !receiptString) {
+        [self handleActionWithType:IAPResultIDError data:nil];
+        return;
+    }
+  
+    
+    [XSNetwork payWithReceipt:receiptString orderId:orderId complete:^(id object, NSError *error) {
+        
+        //TTOO:网络异常,服务器校验receiptString失败,就会出现掉单问题.需要保存订单号到本地,下次启动app,继续校验服务器.
+        NSLog(@"订单校验接口返回:error=%@",error);
+        
+        if (error != nil) {
+             NSLog(@"3333. 服务器返回订单校验失败.");
+            //订单校验失败.
+            [self handleActionWithType:IAPResultVerFailed data:nil];
+        }else{
+            
+            NSLog(@"3333. 服务器返回订单校验成功.");
+            //订单校验成功,删除本地保存的订单号和苹果返回的data凭证.
+            [self handleActionWithType:IAPResultSuccess data:nil];
+            [self removeLocReceiptData];
+        }
+    }];
+}
+
+
+/**
+ 交易失败
+ 
+ @param transaction  内购项目体
+ */
+- (void)failedTransaction:(SKPaymentTransaction *)transaction {
+    if (transaction.error.code != SKErrorPaymentCancelled) {
+        [self handleActionWithType:IAPResultFailed data:nil];
+    } else {
+        [self handleActionWithType:IAPResultCancle data:nil];
+    }
+}
+
+
+#pragma mark -- 本地保存一次支付凭证
+static NSString *const kSaveReceiptData = @"kSaveReceiptData";
+
+- (void)saveReceiptData:(NSDictionary *)receiptData {
+    [[NSUserDefaults standardUserDefaults] setValue:receiptData forKey:kSaveReceiptData];
+    [[NSUserDefaults standardUserDefaults]synchronize];
+}
+
++ (NSDictionary *)getReceiptData {
+    return [[NSUserDefaults standardUserDefaults] valueForKey:kSaveReceiptData];
+}
+
+- (void)removeLocReceiptData {
+    [[NSUserDefaults standardUserDefaults] removeObjectForKey:kSaveReceiptData];
+    [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
+
+/**
+- (void)verifyPurchaseWithPaymentTransaction:(SKPaymentTransaction *)transaction isTestServer:(BOOL)flag {
+    //交易验证
+    NSURL *recepitURL = [[NSBundle mainBundle] appStoreReceiptURL];
+    NSData *receipt = [NSData dataWithContentsOfURL:recepitURL];
+    
+    NSError *error;
+    NSDictionary *requestContents = @{@"receipt-data": [receipt base64EncodedStringWithOptions:0]};
+    NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents options:0 error:&error];
+    if (!requestData) { // 交易凭证为空验证失败
+        [self handleActionWithType:IAPResultVerFailed data:nil];
+        return;
+    }
+    
+    //In the test environment, use https://sandbox.itunes.apple.com/verifyReceipt
+    //In the real environment, use https://buy.itunes.apple.com/verifyReceipt
+    
+    NSString *serverString = @"https://buy.itunes.apple.com/verifyReceipt";
+    if (flag) {
+        serverString = @"https://sandbox.itunes.apple.com/verifyReceipt";
+    }
+    NSURL *storeURL = [NSURL URLWithString:serverString];
+    NSMutableURLRequest *storeRequest = [NSMutableURLRequest requestWithURL:storeURL];
+    [storeRequest setHTTPMethod:@"POST"];
+    [storeRequest setHTTPBody:requestData];
+    storeRequest.timeoutInterval = 20;
+    [storeRequest addValue:@"application/json;charset=utf-8" forHTTPHeaderField:@"Content-Type"];
+    NSURLSession *session = [NSURLSession sharedSession];
+    NSURLSessionDataTask *task = [session dataTaskWithRequest:storeRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
+        if (error) {
+            // 无法连接服务器,购买校验失败
+            [self handleActionWithType:IAPResultVerFailed data:nil];
+        } else {
+            NSError *error;
+            NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
+            if (!jsonResponse) {
+                // 苹果服务器校验数据返回为空校验失败
+                [self handleActionWithType:IAPResultVerFailed data:nil];
+            }
+            
+            // 先验证正式服务器,如果正式服务器返回21007再去苹果测试服务器验证,沙盒测试环境苹果用的是测试服务器
+            NSString *status = [NSString stringWithFormat:@"%@",jsonResponse[@"status"]];
+            if (status && [status isEqualToString:@"21007"]) {
+                [self verifyPurchaseWithPaymentTransaction:transaction isTestServer:YES];
+            } else if(status && [status isEqualToString:@"0"]){
+                [self handleActionWithType:IAPResultVerSuccess data:nil];
+            }
+        }
+    }];
+    [task resume];
+}
+ 
+ */
+
+
+
+//- (KDMainPresenter *)presenter {
+//    if (!_presenter) {
+//        self.presenter = [[KDMainPresenter alloc] init];
+//    }
+//    return _presenter;
+//}
+
+@end

+ 15 - 26
NatureSDK/XenonSDK/XenonOther/XSNetwork.m

@@ -18,6 +18,7 @@
 
 #if SDK_HAS_IAP_PAYMENT
 #import "IAPAgnet.h"
+#import "KDIAPManager.h"
 #endif
 
 
@@ -737,9 +738,11 @@ MBProgressHUD* sdk_net_hud;
         return;
     }
     
+    
     // Send a request to server.
     [self requestWithURL:url parameters:ps model:nil complete:^(id obj, NSError *error) {
         
+        
         if (error != nil) {
             complete(nil, error);
             return;
@@ -753,37 +756,23 @@ MBProgressHUD* sdk_net_hud;
             complete(nil, [XSNetwork errorWithCode:-2 message:@"服务器异常"]);
             return;
         }
-        
-        IAPAgnet* agnet = [[IAPAgnet alloc] init];
-        SKProductsRequest* request = [[SKProductsRequest  alloc] initWithProductIdentifiers:[NSSet setWithObject:productId]];
-        
-        agnet.productId = productId;
-        agnet.orderId = orderId;
-        static IAPAgnet* value = nil;
-        value = agnet;
-        
-        [agnet prepare];
-        
-        [agnet setCallback:^(id order, NSError *error) {
+   
+        [[KDIAPManager shareIAPManager] startIAPWithOrderId:orderId productID:productId completeHandle:^(IAPResultType type, NSData *data) {
             
-            [value clean];
-            value.callback = nil;
-            request.delegate = nil;
-            
-            if (error != nil) {
-                complete(nil, error);
-                return;
+            //complete(nil, [XSNetwork errorWithCode:-2 message:@"购买成功!"]);
+            if (type == IAPResultSuccess) {
+                [XSNetwork showHudSuccess:@"购买成功!"];
+                complete(ps,nil);
+            }else if (type == IAPResultVerFailed){
+                [XSNetwork showHudSuccess:@"订单校验失败!"];
+                complete(nil, [XSNetwork errorWithCode:-1 message:@"订单校验失败!"]);
+            }else{
+                [XSNetwork showHudFailure:@"购买失败!"];
+                complete(nil, [XSNetwork errorWithCode:-1 message:@"购买失败!"]);
             }
-            
-            // Upload receipt information.TTOO:
-            [self payWithReceipt:order orderId:orderId complete:complete];
         }];
-        
-        request.delegate = agnet;
-        [request start];
     }];
 }
-
 /// Pay a product with receipt. 客户端发送苹果的票据到服务器端校验.
 + (void)payWithReceipt:(id)receipt orderId:(id)orderId complete:(void(^)(id object, NSError* error))complete {
     // Prepare request parameters.

+ 0 - 15
NatureSDK/XenonSDK/XenonSDK.h

@@ -86,9 +86,6 @@
 ///横幅广告(Google AdMob)
 - (void)adBanner:(NSString*)adId;
 
-///横幅广告(IronSource)
-//- (void)adIronSourceBanner:(NSString*)adId;
-
 ///关闭广告( banner横幅, nativeAd原生)
 - (void)closeAd:(NSString*)adId;
 
@@ -107,18 +104,6 @@
 //广告是否加载好
 -(BOOL)isAvailableAd:(NSString *)adName;
 
-/// 生命周期启动入口
-/// @param application application对象
-//-(void)applicationDidFinishLaunching:(UIApplication *)application;
-//
-///// 游戏进入后台
-//-(void)applicationDidEnterBackground;
-//
-///// 游戏进入到前台
-//-(void)applicationWillEnterForeground;
-//
-///// 游戏开始活跃运行
-//-(void)applicationDidBecomeActive;
 
 ///手机震动
 -(void)iphoneVibrate;

+ 4 - 76
NatureSDK/XenonSDK/XenonSDK.m

@@ -25,7 +25,7 @@
 #import "UserCenterViewController.h"
 
 #import "XSUtils.h"
-
+#import "KDIAPManager.h"
 #import <objc/message.h>
 
 
@@ -357,78 +357,10 @@
     [XSTracker.shared trace:0x010030];
     
     [XSNetwork showHudLoading];
-    [XSNetwork routeWithComplete:^(id object, NSError *error) {
-        
-        if (error != nil) {
-            [XSNetwork showHudFailure:error];
-            if (complete != nil) {
-                complete(nil, error);
-            }
-            return;
-        }
-        
+    
+
         // Get parmeters.
         XSUser* user = self.user;
-        NSString* path = object[fqsd(@"PREAACs/NCYsJjQuLRkA")];
-        
-#if SDK_HAS_H5_PAYMENT
-        // Generate h5 payment parameters.
-        if (path.length != 0) {
-            
-            [XSNetwork hideHud];
-            [XSTracker.shared trace:0x010031];
-            
-            id payments = @{
-                @"cpBillNo": parameters[@"orderId"] ?: @"",
-                @"orderAmount": parameters[@"amount"] ?: @"",
-                @"subject": parameters[@"productName"] ?: @"",
-                
-                @"roleName": parameters[@"roleName"] ?: @"",
-                @"serverId": parameters[@"serverId"] ?: @"",
-                @"extraInfo": parameters[@"extraInfo"] ?: @"",
-                
-                @"phone": @"",
-                @"isTest": @"1",
-                @"orderPlatform": @"0",
-                @"orderType": @"1",
-                @"remark": @"0",
-                @"isApp": @"0",
-                
-                @"uid": user.uid,
-                @"userName": user.userName ?: @""
-            };
-            
-            NSURLComponents* components = [NSURLComponents componentsWithString:path];
-            NSDictionary* json = [XSNetwork bodyWithParameters:payments];
-            NSString* str = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:json options:0 error:nil] encoding:NSUTF8StringEncoding];
-
-            components.queryItems = @[[NSURLQueryItem queryItemWithName:@"jsonData" value:str],
-                                      [NSURLQueryItem queryItemWithName:@"v" value:@"1"]];
-            
-            if (components.URL == nil) {
-                if (complete != nil) {
-                    complete(nil, [XSNetwork errorWithCode:-1 message:@"后台参数错误"]);
-                }
-                return;
-            }
-            
-            UserCenterViewController* rootViewController = UserCenterViewController.new;
-            rootViewController.custom = components.URL.absoluteString;
-            rootViewController.otherView = self.bubbleView;
-            rootViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
-            self.rootViewController = rootViewController;
-
-            // Cannot get the callback state.
-            rootViewController.callback = ^{
-                if (complete != nil) {
-                    complete(nil, nil);
-                }
-            };
-            return;
-        }
-#endif
-#if SDK_HAS_IAP_PAYMENT
-        // Generate iap payment parameters.
         id payments = @{
             @"productCode": parameters[@"productCode"] ?: @"",
             @"isCoin": @"0",
@@ -451,6 +383,7 @@
         [XSTracker.shared trace:0x010032];
         [XSNetwork payWithParameters:payments complete:^(id object, NSError *error) {
             
+            
             if (error != nil) {
                 [XSNetwork showHudFailure:error];
                 if (complete != nil) {
@@ -465,11 +398,7 @@
             if (complete != nil)
                 complete(payments, nil);
         }];
-#endif
-    }];
-
 }
-
 ///
 /// User Center.
 ///
@@ -997,7 +926,6 @@
     
     XSUser* user1 = [XSDataCenter valueForKey:@"User.current"];
     //PS:通过这种方式获取到的user有值不会为空,其他方法获取的值为空,不准确!!!
-    //XSUser *user1 = self.user;
     
     //未注册,
     if (user1.uid.length == 0) {

+ 23 - 0
README.md

@@ -0,0 +1,23 @@
+SDK Version: 1.0.4(3)
+基本功能: (注意: 旧的UI登录界面。)
+1.   SDK init.
+2.   登录.(游客登录,账号登录...)
+3.   登出.
+4.   个人中心.
+5.   角色上报.
+6.   苹果支付.(新的)
+===============================================================
+新增:
+1.  海外Google AdMob 和ironsource聚合广告.(横幅广告,原生广告,视频激励广告,插页广告, 积分墙广告,)
+2.  Facebook统计
+3.  Firebase统计
+4.  Adjust统计
+5.  工具类(手机震动,跳转苹果商店,)
+6.  自动登录
+7.  手动登录
+8.  自定义统计上报后台服务器
+
+  
+  
+
+

+ 0 - 8
功能介绍.txt

@@ -1,8 +0,0 @@
-Version: 1.0.0
-SDK功能:
-1. 旧的UI登录界面。
-2. 苹果内购功能是旧的代码,有问题。使用ios-adjust工程里的新代码。
-3. 海外Google AdMob 和ironsource广告功能。
-
-
-