88 */
99
1010#import " AppDelegate.h"
11+ #import < RCTJPushModule.h>
12+ #ifdef NSFoundationVersionNumber_iOS_9_x_Max
13+ #import < UserNotifications/UserNotifications.h>
14+ #endif
15+
1116
1217#import < React/RCTBundleURLProvider.h>
1318#import < React/RCTRootView.h>
2025static NSString * g_sampleCodeName = @" #" ;;
2126@implementation AppDelegate
2227
28+ - (void )application : (UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken
29+ {
30+ [JPUSHService registerDeviceToken: deviceToken];
31+ }
32+
33+ - (void )application : (UIApplication *)application didReceiveRemoteNotification : (NSDictionary *)userInfo
34+ {
35+ [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object:userInfo];
36+ }
37+
38+ - (void )application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
39+ {
40+ [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object: notification.userInfo];
41+ }
42+
43+ - (void )application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^) (UIBackgroundFetchResult))completionHandler
44+ {
45+ [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object:userInfo];
46+ }
47+
48+ - (void )jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger ))completionHandler
49+ {
50+ NSDictionary * userInfo = notification.request .content .userInfo ;
51+ if ([notification.request.trigger isKindOfClass: [UNPushNotificationTrigger class ]]) {
52+ [JPUSHService handleRemoteNotification: userInfo];
53+ [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object:userInfo];
54+ }
55+
56+ completionHandler (UNNotificationPresentationOptionAlert );
57+ }
58+
59+ - (void )jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler
60+ {
61+ NSDictionary * userInfo = response.notification .request .content .userInfo ;
62+ if ([response.notification.request.trigger isKindOfClass: [UNPushNotificationTrigger class ]]) {
63+ [JPUSHService handleRemoteNotification: userInfo];
64+ [[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:userInfo];
65+ }
66+
67+ completionHandler ();
68+ }
69+
70+
2371- (void )application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler
2472{
2573 [RNFSManager setCompletionHandlerForIdentifier: identifier completionHandler: completionHandler];
@@ -31,10 +79,13 @@ +(void)SetSampleCodeName:(NSString*)name
3179}
3280- (BOOL )application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
3381{
82+ [JPUSHService setupWithOption: launchOptions appKey: @" 7d2470baad20e273cd6e53cc"
83+ channel: nil apsForProduction: nil ];
84+
3485 NSURL *jsCodeLocation;
3586
3687#if DEBUG
37- [[RCTBundleURLProvider sharedSettings] setJsLocation:@" 192.168.0.102 " ];
88+ [[RCTBundleURLProvider sharedSettings] setJsLocation:@" 192.168.137.204 " ];
3889#endif
3990 jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@" index" fallbackResource:nil ];
4091
0 commit comments