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