소스 검색

跳转URL修改为as相关

“wangdongchao” 1 년 전
부모
커밋
3f14dbba87

+ 2 - 0
Asteria/ASUI/SizeDefine.h

@@ -16,6 +16,8 @@
 //#define Google_clientID @"288779326635-d24uma05320uitu5dr62mdtltnsf62c8.apps.googleusercontent.com"
 #define Google_clientID @"203797423430-b04oap5s9qsgrg8fnsjnu9cntbceqrej.apps.googleusercontent.com"
 
+#define StripePublishableKey  @"pk_test_51MFDGRAxgV55iyHtmJFrPuz4i5cl1y3nhTLVT3EmsHlYLIwsj7TnPRPeulAUXSbOW7gccaVLJmFjVz4eu3E17g6z00TLI1YvoG"
+
 
 #define serviceEmailAdr @"server@asteria.com"
 #define mailServiceUrlStr ([NSString stringWithFormat:@"mailto:%@", serviceEmailAdr])

+ 106 - 7
Asteria/AppDelegate.m

@@ -11,9 +11,12 @@
 #import <FBSDKLoginKit/FBSDKLoginKit.h>
 
 #import <StripeCore/StripeCore-Swift.h>
+
+#import <OneSignal/OneSignal.h>
+
 @import Stripe;
 
-@interface AppDelegate ()
+@interface AppDelegate ()<UNUserNotificationCenterDelegate>
 
 //@property (nonatomic, strong, readonly) UIWindow *window;
 
@@ -30,14 +33,13 @@
         // Fallback on earlier versions
     }
         
-    // 为了使用 Facebook SDK 应该调用如下方法
-   [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
-   // 注册 FacebookAppID
-    [[FBSDKSettings sharedSettings] setAppID:Facebook_AppID];
     
     [ASCurrencyManager.shared getAllCurrencyData];
+    [ASNetTools reqNet_getAdvCoupons];
+    
 //    [self xxx_ytkNetConfig];
     [PPNetworkHelper openLog];
+    
     self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
     AS_TabBarViewController *tab = [[AS_TabBarViewController alloc] init];
     tab.selectedIndex = 0;
@@ -45,11 +47,23 @@
     if (ASUserInfoManager.shared.isLogin ) {
         [ASUserInfoManager.shared getInfo];
     }
-    [ASNetTools reqNet_getAdvCoupons];
     [self.window makeKeyAndVisible];
     
+    //StripeAPI
+    [StripeAPI setDefaultPublishableKey:StripePublishableKey];
     
-    [StripeAPI setDefaultPublishableKey:@"pk_test_51MFDGRAxgV55iyHtmJFrPuz4i5cl1y3nhTLVT3EmsHlYLIwsj7TnPRPeulAUXSbOW7gccaVLJmFjVz4eu3E17g6z00TLI1YvoG"];
+    // 为了使用 Facebook SDK 应该调用如下方法
+    [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
+    // 注册 FacebookAppID
+    [[FBSDKSettings sharedSettings] setAppID:Facebook_AppID];
+    
+    //推送相关配置
+    [self oneSignalPushConfig:launchOptions];
+    
+    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
+    [self pushAuthRequest];
+//    [OneSignal sendTag:@"SufixUid" value:@"-"];
+//    [self updateUserData];
 
     
     return YES;
@@ -133,7 +147,92 @@
     return YES;
 }
 
+- (void)pushAuthRequest {
+    // 申请权限1
+    [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
+        if (settings.authorizationStatus == UNAuthorizationStatusNotDetermined) {
+            UNAuthorizationOptions authOptions =
+            UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
+            [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions
+                                                                                completionHandler:^(BOOL granted, NSError *_Nullable error){
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    [[UIApplication sharedApplication] registerForRemoteNotifications]; //注册获得device Token
+                });
+            }];
+            
+        }
+    }];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[UIApplication sharedApplication] registerForRemoteNotifications]; //注册获得device Token
+    });
+}
+
+
+-(void)oneSignalPushConfig:(NSDictionary *)launchOptions{
+    /*
+//#ifdef DEBUG
+//    [MobPush setAPNsForProduction:NO];
+//#else
+//    [MobPush setAPNsForProduction:YES];
+//#endif
+//    //设置地区:regionId 默认0(国内),1:海外
+//    [MobPush setRegionID:1];
+//    //MobPush推送设置(获得角标、声音、弹框提醒权限)
+//    MPushNotificationConfiguration *configuration = [[MPushNotificationConfiguration alloc] init];
+//    configuration.types = MPushAuthorizationOptionsBadge | MPushAuthorizationOptionsSound | MPushAuthorizationOptionsAlert;
+//    [MobPush setupNotification:configuration];
+//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];
+    */
+    
+    
+    
+    // Remove this method to stop OneSignal Debugging
+      [OneSignal setLogLevel:ONE_S_LL_VERBOSE visualLevel:ONE_S_LL_NONE];
+      
+      // OneSignal initialization
+      [OneSignal initWithLaunchOptions:launchOptions];
+      [OneSignal setAppId:@"618fe580-bc97-4bf4-b2bb-5039f9dbbc82"];
+
+      // promptForPushNotifications will show the native iOS notification permission prompt.
+      // We recommend removing the following code and instead using an In-App Message to prompt for notification permission (See step 8)
+      [OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) {
+        NSLog(@"User accepted notifications: %d", accepted);
+      }];
+    
+    
+      
+      // Set your customer userId
+      // [OneSignal setExternalUserId:@"userId"];
+    
+    // Pass in email provided by customer
+    // [OneSignal setEmail:@"example@domain.com"];
+
+    // Pass in phone number provided by customer
+    // [OneSignal setSMSNumber:@"+11234567890"];
+    
+    
+    // [OneSignal sendTag:@"key" value:@"value"];
+    
+    
+    
+
+    
+    
+#ifdef DEBUG
+    [PPNetworkHelper openLog];
+#else
+    [PPNetworkHelper closeLog];
+#endif
+
+}
 
+- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
+    // 用户点击了通知
+        // 通过response参数处理用户的点击事件
+    completionHandler();
+    NSDictionary *payLoad = response.notification.request.content.userInfo;
+    [self handlePushAction:payLoad];
+}
 
 
 @end

+ 2 - 0
Asteria/Asteria.entitlements

@@ -2,6 +2,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>
 	<key>com.apple.developer.applesignin</key>
 	<array>
 		<string>Default</string>

+ 13 - 8
Asteria/Fuction/Cart/Cart_CheckoutC.m

@@ -256,6 +256,7 @@
             if ([mark isEqualToString:Chectout_giftAddCart]) {
                 self.index --;
                 if (self.index == 0) {
+                    [self.addGiftParamArr removeAllObjects];
                     [self reqNet_Cart_cartsMineTotals];
                 }
             } else {
@@ -340,11 +341,12 @@
     [self.TableV.infodata addObjectsFromArray:self.paymentArray];
     
     //手动添加赠品功能
-    [self.addGiftParamArr removeAllObjects];
-    
     NSDictionary *freeData = (NSDictionary *)[[self.totalsM.extension_attributes objectForKey:@"free_data"] mj_JSONObject];
     BOOL is_show = [[freeData objectForKey:@"is_show"] boolValue];
     if (is_show && self.giftShowCount< 1) {//显示存在赠品
+        
+        [self.addGiftParamArr removeAllObjects];
+        
         NSArray *productArr = [freeData objectForKey:@"products"];
         if (productArr.count > 0) { //存在赠品
             for (int i = 0; i < productArr.count; i++) {
@@ -635,13 +637,16 @@
 
 //赠品加车
 - (void)requestGiftAddCart {
-    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     
-    for (int i = 0; i < self.addGiftParamArr.count; i++) {
-        NSDictionary *param = self.addGiftParamArr[i];
-        self.index ++;
-        self.giftShowCount = 1;
-        [self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
+    if (AS_Array_valid(self.addGiftParamArr)) {
+        [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+        
+        for (int i = 0; i < self.addGiftParamArr.count; i++) {
+            NSDictionary *param = self.addGiftParamArr[i];
+            self.index ++;
+    //        self.giftShowCount = 1;
+            [self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
+        }
     }
 }
 

+ 10 - 3
Asteria/Fuction/Cart/PayManager/ASCheckoutPayManager.m

@@ -110,7 +110,7 @@ static ASCheckoutPayManager *_instance = nil;
             NSDictionary *dataDic = (NSDictionary *)json;
             self.client_token = AS_String_NotNull(dataDic[@"client_token"]);
             //klarna_1 初始化 如果不经历接口创建订单,永远无法更新 client_token 的订单信息
-            [self.klarna_payV initializeWithClientToken:self.client_token returnUrl:[NSURL URLWithString:@"alipearlKlarna://"]];
+            [self.klarna_payV initializeWithClientToken:self.client_token returnUrl:[NSURL URLWithString:@"asteriaKlarna://"]];
             
             NSLog(@"=====%@", json);
         } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
@@ -199,9 +199,11 @@ static ASCheckoutPayManager *_instance = nil;
         
         NSDictionary *payReturnDic = (NSDictionary *)json;
         
-        NSString *orderid = [payReturnDic objectForKey:@"incrementId"];
+        NSString *orderid = [payReturnDic objectForKey:@"id"];
+        NSString *orderNum = [payReturnDic objectForKey:@"incrementId"];
+
         if (self.payFinishBlock) {
-            self.payFinishBlock(self.payType, 1, @{@"orderid":orderid});
+            self.payFinishBlock(self.payType, 1, @{@"orderid":orderid, @"orderNum":orderNum});
         }
     } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
         K_STRONG_SELF;
@@ -284,6 +286,11 @@ static ASCheckoutPayManager *_instance = nil;
         [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
         
         NSString *orderid = (NSString *)json;
+//        NSString *orderNum = [payReturnDic objectForKey:@"incrementId"];
+
+        if (self.payFinishBlock) {
+            self.payFinishBlock(self.payType, 1, @{@"orderid":orderid});
+        }
         NSLog(@"=======%@", orderid);
         if (self.payFinishBlock) {
             self.payFinishBlock(self.payType, 1, @{@"orderid":orderid});

+ 2 - 2
Asteria/Fuction/Cart/PayManager/ToolStripePayment.swift

@@ -73,8 +73,8 @@ public class ToolStripePayment: NSObject {
 //        let customer = PaymentSheet.CustomerConfiguration(id: "845600348@qq.com", ephemeralKeySecret: configuration.customer!.ephemeralKeySecret)
 //////
 //        configuration.customer = customer
-        configuration.applePay = .init(merchantId: "merchant.com.alipearlhair.app", merchantCountryCode: "US")
-        configuration.returnURL = "alipearlStripe://stripe-redirect" // Use the return url you set up in the previous step
+        configuration.applePay = .init(merchantId: "merchant.com.asteriahair.app", merchantCountryCode: "US")
+        configuration.returnURL = "asteriaStripe://stripe-redirect" // Use the return url you set up in the previous step
         configuration.allowsDelayedPaymentMethods = true
         
         

+ 5 - 5
Asteria/Info.plist

@@ -29,7 +29,7 @@
 			<string>Editor</string>
 			<key>CFBundleURLSchemes</key>
 			<array>
-				<string>com.alipearlhair.app.payments</string>
+				<string>com.asteriahair.app.payments</string>
 			</array>
 		</dict>
 		<dict>
@@ -69,7 +69,7 @@
 			<string>Editor</string>
 			<key>CFBundleURLSchemes</key>
 			<array>
-				<string>com.alipearlhair.app</string>
+				<string>com.asteriahair.app</string>
 			</array>
 		</dict>
 		<dict>
@@ -93,7 +93,7 @@
 			<string>Editor</string>
 			<key>CFBundleURLSchemes</key>
 			<array>
-				<string>alipearlhairKlarna</string>
+				<string>asteriahairKlarna</string>
 			</array>
 		</dict>
 		<dict>
@@ -117,7 +117,7 @@
 			<string>Editor</string>
 			<key>CFBundleURLSchemes</key>
 			<array>
-				<string>alipearlKlarna</string>
+				<string>asteriaKlarna</string>
 			</array>
 		</dict>
 		<dict>
@@ -125,7 +125,7 @@
 			<string>Editor</string>
 			<key>CFBundleURLSchemes</key>
 			<array>
-				<string>alipearlStripe</string>
+				<string>asteriaStripe</string>
 			</array>
 		</dict>
 	</array>