mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-03-16 05:51:04 +08:00
move jpush sdk inital method to JPushPlugin static method
This commit is contained in:
parent
cbca41a513
commit
40828ff145
@ -17,9 +17,17 @@ static NSDictionary *_luanchOptions=nil;
|
|||||||
|
|
||||||
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
|
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
|
||||||
_luanchOptions=theLaunchOptions;
|
_luanchOptions=theLaunchOptions;
|
||||||
|
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
|
||||||
|
UIUserNotificationTypeSound |
|
||||||
|
UIUserNotificationTypeAlert)
|
||||||
|
categories:nil];
|
||||||
|
[APService setupWithOption:_luanchOptions];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)initial:(CDVInvokedUrlCommand*)command{
|
||||||
|
//do nithng,because Cordova plugin use lazy load mode.
|
||||||
|
|
||||||
|
}
|
||||||
- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView{
|
- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView{
|
||||||
if (self=[super initWithWebView:theWebView]) {
|
if (self=[super initWithWebView:theWebView]) {
|
||||||
|
|
||||||
@ -35,11 +43,9 @@ static NSDictionary *_luanchOptions=nil;
|
|||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
if (!_luanchOptions) {
|
if (!_luanchOptions) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
NSDictionary *userInfo = [_luanchOptions
|
NSDictionary *userInfo = [_luanchOptions
|
||||||
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
||||||
if (_luanchOptions && [userInfo count] >0) {
|
if ([userInfo count] >0) {
|
||||||
NSError *error;
|
NSError *error;
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
@ -53,20 +59,9 @@ static NSDictionary *_luanchOptions=nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)init:(CDVInvokedUrlCommand*)command{
|
|
||||||
if (!_luanchOptions) {
|
|
||||||
NSLog("must set [JPushPlugin setLaunchOptions:launchOptions] in AppDelegate.m"):
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
|
return self;
|
||||||
UIUserNotificationTypeSound |
|
|
||||||
UIUserNotificationTypeAlert)
|
|
||||||
categories:nil];
|
|
||||||
[APService setupWithOption:_luanchOptions];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
||||||
|
@ -230,10 +230,15 @@ JPushPlugin.prototype.isPushStopped = function(callback){
|
|||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.init = function(){
|
JPushPlugin.prototype.init = function(){
|
||||||
if(device.platform == "Android") {
|
if(this.isPlatformIOS()){
|
||||||
|
var data=[];
|
||||||
|
this.call_native("initial",data,null);
|
||||||
|
}else{
|
||||||
data=[];
|
data=[];
|
||||||
this.call_native("init",data,null);
|
this.call_native("init",data,null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setDebugMode = function(mode){
|
JPushPlugin.prototype.setDebugMode = function(mode){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user