mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-03-03 21:32:51 +08:00
Merge branch 'dev'
This commit is contained in:
commit
469af4fcd3
@ -1,7 +1,7 @@
|
|||||||
# JPush PhoneGap / Cordova Plugin
|
# JPush PhoneGap / Cordova Plugin
|
||||||
|
|
||||||
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin)
|
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "3.2.9",
|
"version": "3.2.10",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="jpush-phonegap-plugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="3.2.9">
|
version="3.2.10">
|
||||||
|
|
||||||
<name>JPush</name>
|
<name>JPush</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
|
@ -28,25 +28,20 @@
|
|||||||
return [self init_plus];
|
return [self init_plus];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)fireOpenNotification:(NSTimer*)timer{
|
|
||||||
if (SharedJPushPlugin) {
|
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[timer.userInfo toJsonString]];
|
|
||||||
[timer invalidate];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NSDictionary *_launchOptions;
|
NSDictionary *_launchOptions;
|
||||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||||
|
|
||||||
|
if (!_jpushEventCache) {
|
||||||
|
_jpushEventCache = @{}.mutableCopy;
|
||||||
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jpushSDKDidLoginNotification) name:kJPFNetworkDidLoginNotification object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jpushSDKDidLoginNotification) name:kJPFNetworkDidLoginNotification object:nil];
|
||||||
|
|
||||||
if (notification) {
|
if (notification) {
|
||||||
if (notification.userInfo) {
|
if (notification.userInfo) {
|
||||||
|
|
||||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
||||||
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:)
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[notification.userInfo toJsonString]];
|
||||||
userInfo:[notification.userInfo
|
|
||||||
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey] repeats:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
||||||
@ -56,7 +51,7 @@ NSDictionary *_launchOptions;
|
|||||||
@"badge": @(localNotification.applicationIconBadgeNumber),
|
@"badge": @(localNotification.applicationIconBadgeNumber),
|
||||||
@"extras":localNotification.userInfo,
|
@"extras":localNotification.userInfo,
|
||||||
};
|
};
|
||||||
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:localNotificationEvent repeats:YES];
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#import <Cordova/CDV.h>
|
#import <Cordova/CDV.h>
|
||||||
|
|
||||||
|
NSMutableDictionary *_jpushEventCache;
|
||||||
|
|
||||||
@interface JPushPlugin : CDVPlugin{
|
@interface JPushPlugin : CDVPlugin{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,12 +83,31 @@
|
|||||||
selector:@selector(receiveLocalNotification:)
|
selector:@selector(receiveLocalNotification:)
|
||||||
name:JPushDocumentEvent_ReceiveLocalNotification
|
name:JPushDocumentEvent_ReceiveLocalNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
[self dispatchJPushCacheEvent];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dispatchJPushCacheEvent {
|
||||||
|
for (NSString* key in _jpushEventCache) {
|
||||||
|
NSArray *evenList = _jpushEventCache[key];
|
||||||
|
for (NSString *event in evenList) {
|
||||||
|
[JPushPlugin fireDocumentEvent:key jsString:event];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
|
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
|
||||||
|
if (SharedJPushPlugin) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[SharedJPushPlugin.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.%@',%@)", eventName, jsString]];
|
[SharedJPushPlugin.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.%@',%@)", eventName, jsString]];
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_jpushEventCache[eventName]) {
|
||||||
|
_jpushEventCache[eventName] = @[].mutableCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_jpushEventCache[eventName] addObject: jsString];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setTags:(CDVInvokedUrlCommand*)command {
|
-(void)setTags:(CDVInvokedUrlCommand*)command {
|
||||||
|
Loading…
Reference in New Issue
Block a user