mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
add jpush event cache
This commit is contained in:
@@ -38,6 +38,10 @@
|
|||||||
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) {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user