mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
iOS - add API
1.增加延迟启动 API 2.增加 doc 说明 3.优化代码
This commit is contained in:
@@ -39,6 +39,10 @@
|
||||
|
||||
@implementation JPushPlugin
|
||||
|
||||
-(void)startJPushSDK:(CDVInvokedUrlCommand*)command{
|
||||
[(AppDelegate*)[UIApplication sharedApplication].delegate startJPushSDK];
|
||||
}
|
||||
|
||||
#pragma mark- 外部接口
|
||||
-(void)stopPush:(CDVInvokedUrlCommand*)command{
|
||||
[[UIApplication sharedApplication]unregisterForRemoteNotifications];
|
||||
@@ -55,18 +59,13 @@
|
||||
|
||||
-(void)initial:(CDVInvokedUrlCommand*)command{
|
||||
//do nithng,because Cordova plugin use lazy load mode.
|
||||
SharedJPushPlugin = self;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(networkDidReceiveMessage:)
|
||||
name:kJPFNetworkDidReceiveMessageNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
#ifdef __CORDOVA_4_0_0
|
||||
|
||||
- (void)pluginInitialize {
|
||||
NSLog(@"### pluginInitialize ");
|
||||
SharedJPushPlugin = self;
|
||||
[self initPlugin];
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -75,12 +74,22 @@
|
||||
NSLog(@"### initWithWebView ");
|
||||
if (self=[super initWithWebView:theWebView]) {
|
||||
}
|
||||
SharedJPushPlugin = self;
|
||||
[self initPlugin];
|
||||
return self;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
-(void)initPlugin{
|
||||
if (!SharedJPushPlugin) {
|
||||
SharedJPushPlugin = self;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(networkDidReceiveMessage:)
|
||||
name:kJPFNetworkDidReceiveMessageNotification
|
||||
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]];
|
||||
|
||||
Reference in New Issue
Block a user