Leon 1 yıl önce
ebeveyn
işleme
164e9c5a8a

+ 5 - 0
ios/AppDelegate.mm

@@ -60,6 +60,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
   UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
   center.delegate = self;
   
+  
 #if RCT_NEW_ARCH_ENABLED
   _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
   _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
@@ -384,5 +385,9 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
     [center removeAllDeliveredNotifications];
 }
 
+- (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification{
+  NSLog(@"open setting");
+}
+
 
 @end

+ 0 - 15
ios/AppDelegateTemp.h

@@ -1,15 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-#import <React/RCTBridgeDelegate.h>
-#import <UIKit/UIKit.h>
-
-@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
-
-@property (nonatomic, strong) UIWindow *window;
-
-@end

+ 0 - 131
ios/AppDelegateTemp.mm

@@ -1,131 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-#import "AppDelegate.h"
-
-#import <RCTJPushModule.h>
-
-#import <React/RCTBridge.h>
-#import <React/RCTBundleURLProvider.h>
-#import <React/RCTRootView.h>
-
-#ifdef NSFoundationVersionNumber_iOS_9_x_Max
-#import <UserNotifications/UserNotifications.h>
-#endif
-
-@interface AppDelegate ()<JPUSHRegisterDelegate>
-
-@end
-
-@implementation AppDelegate
-
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
-  // JPush初始化配置 可以延时初始化 不再强制在此初始化,在js里可以直接调用init
-//  [JPUSHService setupWithOption:launchOptions appKey:@"02c7f79c9248ecadf25140f7"
-//                        channel:@"dev" apsForProduction:YES];
-  // APNS
-  JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
-  if (@available(iOS 12.0, *)) {
-    entity.types = JPAuthorizationOptionNone; //JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSou//nd|JPAuthorizationOptionProvidesAppNotificationSettings;
-  }
-  [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
-  
-  
-//  [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
-//  // 自定义消息
-//  NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
-//  [defaultCenter addObserver:self selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidReceiveMessageNotification object:nil];
-//  // 地理围栏
-//  [JPUSHService registerLbsGeofenceDelegate:self withLaunchOptions:launchOptions];
-  // ReactNative环境配置
-  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
-  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
-                                                   moduleName:@"example"
-                                            initialProperties:nil];
-  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
-  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
-  UIViewController *rootViewController = [UIViewController new];
-  rootViewController.view = rootView;
-  self.window.rootViewController = rootViewController;
-  [self.window makeKeyAndVisible];
-  return YES;
-}
-
-- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
-{
-#if DEBUG
-  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
-#else
-  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
-#endif
-}
-
-//************************************************JPush start************************************************
-
-//注册 APNS 成功并上报 DeviceToken
-- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
-  [JPUSHService registerDeviceToken:deviceToken];
-}
-
-//iOS 7 APNS
-- (void)application:(UIApplication *)application didReceiveRemoteNotification:  (NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
-  // iOS 10 以下 Required
-  NSLog(@"iOS 7 APNS");
-  [JPUSHService handleRemoteNotification:userInfo];
-  [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_ARRIVED_EVENT object:userInfo];
-  completionHandler(UIBackgroundFetchResultNewData);
-}
-
-//iOS 10 前台收到消息
-- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center  willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
-  NSDictionary * userInfo = notification.request.content.userInfo;
-  if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
-    // Apns
-    NSLog(@"iOS 10 APNS 前台收到消息");
-    [JPUSHService handleRemoteNotification:userInfo];
-    [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_ARRIVED_EVENT object:userInfo];
-  }
-  else {
-    // 本地通知 todo
-    NSLog(@"iOS 10 本地通知 前台收到消息");
-    [[NSNotificationCenter defaultCenter] postNotificationName:J_LOCAL_NOTIFICATION_ARRIVED_EVENT object:userInfo];
-  }
-  //需要执行这个方法,选择是否提醒用户,有 Badge、Sound、Alert 三种类型可以选择设置
-  completionHandler(UNNotificationPresentationOptionAlert);
-}
-
-//iOS 10 消息事件回调
-- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler: (void (^)(void))completionHandler {
-  NSDictionary * userInfo = response.notification.request.content.userInfo;
-  if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
-    // Apns
-    NSLog(@"iOS 10 APNS 消息事件回调");
-    [JPUSHService handleRemoteNotification:userInfo];
-    // 保障应用被杀死状态下,用户点击推送消息,打开app后可以收到点击通知事件
-    [[RCTJPushEventQueue sharedInstance]._notificationQueue insertObject:userInfo atIndex:0];
-    [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_OPENED_EVENT object:userInfo];
-  }
-  else {
-    // 本地通知
-    NSLog(@"iOS 10 本地通知 消息事件回调");
-    // 保障应用被杀死状态下,用户点击推送消息,打开app后可以收到点击通知事件
-    [[RCTJPushEventQueue sharedInstance]._localNotificationQueue insertObject:userInfo atIndex:0];
-    [[NSNotificationCenter defaultCenter] postNotificationName:J_LOCAL_NOTIFICATION_OPENED_EVENT object:userInfo];
-  }
-  // 系统要求执行这个方法
-  completionHandler();
-}
-
-//自定义消息
-- (void)networkDidReceiveMessage:(NSNotification *)notification {
-  NSDictionary * userInfo = [notification userInfo];
-  [[NSNotificationCenter defaultCenter] postNotificationName:J_CUSTOM_NOTIFICATION_EVENT object:userInfo];
-}
-
-//************************************************JPush end************************************************
-
-@end

+ 1 - 1
ios/NativeBridge.m

@@ -128,7 +128,7 @@ RCT_EXPORT_METHOD(getNotificationAuthStatus){
 RCT_EXPORT_METHOD(authNotification){
   dispatch_async(dispatch_get_main_queue(), ^{
     UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
-    [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
+    [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge|UNAuthorizationOptionProvidesAppNotificationSettings) completionHandler:^(BOOL granted, NSError * _Nullable error) {
       if (granted) {
         [self.bridge.eventDispatcher sendAppEventWithName:@"operateNotificationResult" body:@"authorized"];
         dispatch_async(dispatch_get_main_queue(), ^{

+ 4 - 0
ios/hola.xcodeproj/project.pbxproj

@@ -14,6 +14,7 @@
 		35319C272B2773AB00471ACA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 35319C262B2773AB00471ACA /* libz.tbd */; };
 		35319C292B2773B600471ACA /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 35319C282B2773B600471ACA /* libresolv.tbd */; };
 		35319C2B2B2773BE00471ACA /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35319C2A2B2773BE00471ACA /* UserNotifications.framework */; };
+		3582DF402C29207800276327 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3582DF3F2C29207800276327 /* StoreKit.framework */; };
 		35B0D6E02B4D4EE10059F156 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35B0D6DF2B4D4EE10059F156 /* AppDelegate.mm */; };
 		35B0D6EB2B5B872F0059F156 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 35B0D6E92B5B872F0059F156 /* assets */; };
 		35B0D6ED2B5B8D360059F156 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 35B0D6EC2B5B8D360059F156 /* main.jsbundle */; };
@@ -48,6 +49,7 @@
 		35319C262B2773AB00471ACA /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
 		35319C282B2773B600471ACA /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
 		35319C2A2B2773BE00471ACA /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
+		3582DF3F2C29207800276327 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
 		35B0D6DE2B4D4EE10059F156 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		35B0D6DF2B4D4EE10059F156 /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; };
 		35B0D6E12B4D58540059F156 /* hola.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = hola.entitlements; path = hola/hola.entitlements; sourceTree = "<group>"; };
@@ -81,6 +83,7 @@
 			files = (
 				1616AFC2E937999F0F295448 /* libPods-hola.a in Frameworks */,
 				35319C2B2B2773BE00471ACA /* UserNotifications.framework in Frameworks */,
+				3582DF402C29207800276327 /* StoreKit.framework in Frameworks */,
 				35319C292B2773B600471ACA /* libresolv.tbd in Frameworks */,
 				35319C272B2773AB00471ACA /* libz.tbd in Frameworks */,
 			);
@@ -128,6 +131,7 @@
 		2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				3582DF3F2C29207800276327 /* StoreKit.framework */,
 				35319C2A2B2773BE00471ACA /* UserNotifications.framework */,
 				35319C282B2773B600471ACA /* libresolv.tbd */,
 				35319C262B2773AB00471ACA /* libz.tbd */,