mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 21:43:02 +08:00
iOS - fix #194
This commit is contained in:
parent
df6adddc75
commit
6734bf9160
@ -39,7 +39,7 @@
|
|||||||
<header-file src="src/ios/lib/JPUSHService.h" />
|
<header-file src="src/ios/lib/JPUSHService.h" />
|
||||||
<source-file src="src/ios/lib/jpush-ios-3.0.0.a" framework="true" />
|
<source-file src="src/ios/lib/jpush-ios-3.0.0.a" framework="true" />
|
||||||
<source-file src="src/ios/lib/jcore-ios-1.0.0.a" framework="true" />
|
<source-file src="src/ios/lib/jcore-ios-1.0.0.a" framework="true" />
|
||||||
<resource-file src="src/ios/PushConfig.plist" />
|
<resource-file src="src/ios/JPushConfig.plist" />
|
||||||
|
|
||||||
<framework src="CFNetwork.framework" weak="true" />
|
<framework src="CFNetwork.framework" weak="true" />
|
||||||
<framework src="CoreFoundation.framework" weak="true" />
|
<framework src="CoreFoundation.framework" weak="true" />
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Appkey</key>
|
<key>Appkey</key>
|
||||||
<string>1c29cb5814072b5b1f8ef829</string>
|
<string></string>
|
||||||
<key>Channel</key>
|
<key>Channel</key>
|
||||||
<string>Subscription</string>
|
<string>channel name</string>
|
||||||
<key>IsProduction</key>
|
<key>IsProduction</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>IsIDFA</key>
|
<key>IsIDFA</key>
|
@ -31,15 +31,26 @@
|
|||||||
NSDictionary *_launchOptions;
|
NSDictionary *_launchOptions;
|
||||||
|
|
||||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||||
|
|
||||||
if (notification) {
|
if (notification) {
|
||||||
if (notification.userInfo) {
|
if (notification.userInfo) {
|
||||||
NSDictionary *userInfo1 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
NSDictionary *userInfo1 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
||||||
if (userInfo1.count > 0) {
|
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];
|
NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
|
||||||
if (userInfo2.count > 0) {
|
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];
|
[JPUSHService setDebugMode];
|
||||||
@ -91,7 +102,7 @@ NSDictionary *_launchOptions;
|
|||||||
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
|
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
|
||||||
[JPUSHService handleRemoteNotification: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{
|
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
|
||||||
@ -110,30 +121,23 @@ NSDictionary *_launchOptions;
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
[SharedJPushPlugin jpushFireDocumentEvent:eventName jsString:[userInfo toJsonString]];
|
[JPushPlugin fireDocumentEvent:eventName jsString:[userInfo toJsonString]];
|
||||||
completionHandler(UIBackgroundFetchResultNewData);
|
completionHandler(UIBackgroundFetchResultNewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||||
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||||
if ([SharedJPushPlugin respondsToSelector:@selector(jpushFireDocumentEvent:jsString:)]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
[SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
|
||||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
-(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];
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
||||||
@try {
|
@try {
|
||||||
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
||||||
} @catch (NSException *exception) { }
|
} @catch (NSException *exception) { }
|
||||||
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
||||||
[SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
||||||
completionHandler();
|
completionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#define WEAK_SELF(weakSelf) __weak __typeof(&*self)weakSelf = self;
|
#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_Appkey = @"Appkey";
|
||||||
static NSString *const JPushConfig_Channel = @"Channel";
|
static NSString *const JPushConfig_Channel = @"Channel";
|
||||||
static NSString *const JPushConfig_IsProduction = @"IsProduction";
|
static NSString *const JPushConfig_IsProduction = @"IsProduction";
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
# pragma mark - private
|
# pragma mark - private
|
||||||
|
|
||||||
-(void)jpushFireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
|
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
|
||||||
|
|
||||||
+(void)setupJPushSDK:(NSDictionary*)userInfo;
|
+(void)setupJPushSDK:(NSDictionary*)userInfo;
|
||||||
|
|
||||||
|
@ -90,10 +90,8 @@
|
|||||||
object:nil];
|
object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)jpushFireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
|
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
[SharedJPushPlugin.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.%@',%@)", eventName, jsString]];
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.%@',%@)", eventName, jsString]];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
||||||
@ -322,12 +320,12 @@
|
|||||||
@"tags" :tags == nil ? [NSNull null] : [tags allObjects],
|
@"tags" :tags == nil ? [NSNull null] : [tags allObjects],
|
||||||
@"alias" :alias == nil ? [NSNull null] : alias
|
@"alias" :alias == nil ? [NSNull null] : alias
|
||||||
};
|
};
|
||||||
[self jpushFireDocumentEvent:JPushDocumentEvent_SetTagsWithAlias jsString:[dict toJsonString]];
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_SetTagsWithAlias jsString:[dict toJsonString]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
||||||
if (notification && notification.userInfo) {
|
if (notification && notification.userInfo) {
|
||||||
[self jpushFireDocumentEvent:JPushDocumentEvent_ReceiveMessage jsString:[notification.userInfo toJsonString]];
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveMessage jsString:[notification.userInfo toJsonString]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user