mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 04:32:59 +08:00
add jpush event cache
This commit is contained in:
parent
66932a8bc8
commit
3129165d3f
@ -38,6 +38,10 @@
|
||||
NSDictionary *_launchOptions;
|
||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||
|
||||
if (!_jpushEventCache) {
|
||||
_jpushEventCache = @{}.mutableCopy;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jpushSDKDidLoginNotification) name:kJPFNetworkDidLoginNotification object:nil];
|
||||
|
||||
if (notification) {
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
NSMutableDictionary *_jpushEventCache;
|
||||
|
||||
@interface JPushPlugin : CDVPlugin{
|
||||
|
||||
}
|
||||
|
@ -83,12 +83,31 @@
|
||||
selector:@selector(receiveLocalNotification:)
|
||||
name:JPushDocumentEvent_ReceiveLocalNotification
|
||||
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{
|
||||
if (SharedJPushPlugin) {
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user