diff --git a/plugin.xml b/plugin.xml
index ce097a7..d6422ac 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -39,7 +39,7 @@
-
+
diff --git a/src/ios/PushConfig.plist b/src/ios/JPushConfig.plist
similarity index 81%
rename from src/ios/PushConfig.plist
rename to src/ios/JPushConfig.plist
index ed5d3e9..e5a23bf 100644
--- a/src/ios/PushConfig.plist
+++ b/src/ios/JPushConfig.plist
@@ -3,9 +3,9 @@
Appkey
- 1c29cb5814072b5b1f8ef829
+
Channel
- Subscription
+ channel name
IsProduction
IsIDFA
diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m
index 21cb7eb..862b1e7 100644
--- a/src/ios/Plugins/AppDelegate+JPush.m
+++ b/src/ios/Plugins/AppDelegate+JPush.m
@@ -31,15 +31,26 @@
NSDictionary *_launchOptions;
-(void)applicationDidLaunch:(NSNotification *)notification{
+
if (notification) {
if (notification.userInfo) {
NSDictionary *userInfo1 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (userInfo1.count > 0) {
- [SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo1 toJsonString]];
+ [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) {
+ if (SharedJPushPlugin) {
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo1 toJsonString]];
+ [timer invalidate];
+ }
+ }];
}
NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (userInfo2.count > 0) {
- [SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_StartLocalNotification jsString:[userInfo1 toJsonString]];
+ [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) {
+ if (SharedJPushPlugin) {
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo2 toJsonString]];
+ [timer invalidate];
+ }
+ }];
}
}
[JPUSHService setDebugMode];
@@ -91,7 +102,7 @@ NSDictionary *_launchOptions;
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
[JPUSHService handleRemoteNotification:userInfo];
- [SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
@@ -110,30 +121,23 @@ NSDictionary *_launchOptions;
default:
break;
}
- [SharedJPushPlugin jpushFireDocumentEvent:eventName jsString:[userInfo toJsonString]];
+ [JPushPlugin fireDocumentEvent:eventName jsString:[userInfo toJsonString]];
completionHandler(UIBackgroundFetchResultNewData);
}
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
-
- if ([SharedJPushPlugin respondsToSelector:@selector(jpushFireDocumentEvent:jsString:)]) {
-
- }
- [SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
}
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
- if ([SharedJPushPlugin respondsToSelector:@selector(jpushFireDocumentEvent:jsString:)]) {
-
- }
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
@try {
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
} @catch (NSException *exception) { }
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
- [SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
completionHandler();
}
diff --git a/src/ios/Plugins/JPushDefine.h b/src/ios/Plugins/JPushDefine.h
index 02e59af..357b0ad 100644
--- a/src/ios/Plugins/JPushDefine.h
+++ b/src/ios/Plugins/JPushDefine.h
@@ -15,7 +15,7 @@
#define WEAK_SELF(weakSelf) __weak __typeof(&*self)weakSelf = self;
-static NSString *const JPushConfig_FileName = @"PushConfig";
+static NSString *const JPushConfig_FileName = @"JPushConfig";
static NSString *const JPushConfig_Appkey = @"Appkey";
static NSString *const JPushConfig_Channel = @"Channel";
static NSString *const JPushConfig_IsProduction = @"IsProduction";
diff --git a/src/ios/Plugins/JPushPlugin.h b/src/ios/Plugins/JPushPlugin.h
index 1befbfd..daf08b2 100644
--- a/src/ios/Plugins/JPushPlugin.h
+++ b/src/ios/Plugins/JPushPlugin.h
@@ -75,7 +75,7 @@
# pragma mark - private
--(void)jpushFireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
++(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
+(void)setupJPushSDK:(NSDictionary*)userInfo;
diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m
index 8f6f1b3..9c15fc6 100644
--- a/src/ios/Plugins/JPushPlugin.m
+++ b/src/ios/Plugins/JPushPlugin.m
@@ -90,10 +90,8 @@
object:nil];
}
--(void)jpushFireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.%@',%@)", eventName, jsString]];
- });
++(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
+ [SharedJPushPlugin.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.%@',%@)", eventName, jsString]];
}
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
@@ -322,12 +320,12 @@
@"tags" :tags == nil ? [NSNull null] : [tags allObjects],
@"alias" :alias == nil ? [NSNull null] : alias
};
- [self jpushFireDocumentEvent:JPushDocumentEvent_SetTagsWithAlias jsString:[dict toJsonString]];
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_SetTagsWithAlias jsString:[dict toJsonString]];
}
- (void)networkDidReceiveMessage:(NSNotification *)notification {
if (notification && notification.userInfo) {
- [self jpushFireDocumentEvent:JPushDocumentEvent_ReceiveMessage jsString:[notification.userInfo toJsonString]];
+ [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveMessage jsString:[notification.userInfo toJsonString]];
}
}