mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-19 05:22:57 +08:00
aplace new lib and change demo
This commit is contained in:
parent
d86b2aaefc
commit
334cda7486
@ -25,6 +25,7 @@ cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git
|
||||
1.使用PhoneGap/Cordova CLI命令安装
|
||||
```
|
||||
cordova plugin add https://github.com/zhangqinghe/test.phonegap.git
|
||||
cordova platforms add ios
|
||||
cordova build ios
|
||||
```
|
||||
|
||||
|
BIN
example/.DS_Store
vendored
BIN
example/.DS_Store
vendored
Binary file not shown.
@ -20,22 +20,18 @@
|
||||
initiateUI();
|
||||
}
|
||||
var initiateUI = function() {
|
||||
$("#setAliasButton").click(function(ev) {
|
||||
console.log("setAliasButton");
|
||||
try{window.plugins.jPushPlugin.setAlias("myAlias");}
|
||||
catch(exception){console.log(exception);}
|
||||
|
||||
})
|
||||
$("#setTagButton").click(function(ev) {
|
||||
console.log("setTagButton");
|
||||
try{window.plugins.jPushPlugin.setTags("myAlias");}
|
||||
catch(exception){console.log(exception);}
|
||||
|
||||
})
|
||||
$("#setTagWithAliasButton").click(function(ev) {
|
||||
console.log("setTagWithAliasButton");
|
||||
try{window.plugins.jPushPlugin.setTagsWithAlias("myTags","myTags1","myTags2","myAlias");}
|
||||
catch(exception){console.log(exception);}
|
||||
console.log("tap set tag/alias button!");
|
||||
|
||||
try{
|
||||
var tag1 = $("#tagText1").attr("value");
|
||||
console.log("tag1:"+tag1);
|
||||
|
||||
window.plugins.jPushPlugin.setTagsWithAlias("myTags","myTags1","myTags2","myAlias");
|
||||
}
|
||||
catch(exception){
|
||||
console.log(exception);
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
@ -57,18 +53,37 @@
|
||||
<div data-role="fieldcontain">
|
||||
<center><h3>JPushPlugin Example</h3></center>
|
||||
<span name="alias" id="alias"></span><hr />
|
||||
<label>Alias: </label>
|
||||
<input type="button" id="setAliasButton" value="Set alias" />
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label>Tags: </label>
|
||||
<input type="button" id="setTagButton" value="Add tag" />
|
||||
<div id="tags"></div>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText1"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText2"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText3">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<label>Alias: </label>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="aliasText">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label>Tags and Alias: </label>
|
||||
<input type="button" id="setTagWithAliasButton" value="Add tag and alias" />
|
||||
<div id="tags"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -15,4 +15,5 @@
|
||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)setTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)setAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
|
||||
@end
|
||||
|
@ -59,7 +59,7 @@
|
||||
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias{
|
||||
|
||||
|
||||
NSLog(@"recode is %d tags is %@ alias %@",resultCode,tags,alias);
|
||||
//NSLog(@"recode is %d tags is %@ alias %@",resultCode,tags,alias);
|
||||
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt:resultCode],@"resultCode",
|
||||
tags==nil?[NSNull null]:[tags allObjects],@"resultTags",
|
||||
@ -72,6 +72,9 @@
|
||||
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
|
||||
});
|
||||
}
|
||||
|
||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@ -4,36 +4,65 @@
|
||||
//
|
||||
// Created by JPush on 12-8-15.
|
||||
// Copyright (c) 2012年 HXHG. All rights reserved.
|
||||
// Version: 1.6.2
|
||||
// Version: 1.7.1
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString * const kAPNetworkDidSetupNotification; // 建立连接
|
||||
extern NSString * const kAPNetworkDidCloseNotification; // 关闭连接
|
||||
extern NSString * const kAPNetworkDidRegisterNotification; // 注册成功
|
||||
extern NSString * const kAPNetworkDidLoginNotification; // 登录成功
|
||||
extern NSString * const kAPNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
|
||||
extern NSString * const kAPServiceErrorNotification; // 错误提示
|
||||
|
||||
extern NSString *const kAPNetworkDidSetupNotification; // 建立连接
|
||||
extern NSString *const kAPNetworkDidCloseNotification; // 关闭连接
|
||||
extern NSString *const kAPNetworkDidRegisterNotification; // 注册成功
|
||||
extern NSString *const kAPNetworkDidLoginNotification; // 登录成功
|
||||
extern NSString *const
|
||||
kAPNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
|
||||
extern NSString *const kAPServiceErrorNotification; // 错误提示
|
||||
|
||||
@interface APService : NSObject
|
||||
|
||||
// 以下四个接口是必须调用的
|
||||
+ (void)setupWithOption:(NSDictionary *)launchingOption; // 初始化
|
||||
+ (void)registerForRemoteNotificationTypes:(int)types; // 注册APNS类型
|
||||
+ (void)registerDeviceToken:(NSData *)deviceToken; // 向服务器上报Device Token
|
||||
+ (void)handleRemoteNotification:(NSDictionary *)remoteInfo; // 处理收到的APNS消息,向服务器上报收到APNS消息
|
||||
+ (void)setupWithOption:(NSDictionary *)launchingOption; // 初始化
|
||||
+ (void)registerForRemoteNotificationTypes:(int)types; // 注册APNS类型
|
||||
+ (void)registerDeviceToken:(NSData *)deviceToken; // 向服务器上报Device Token
|
||||
+ (void)handleRemoteNotification:(NSDictionary *)
|
||||
remoteInfo; // 处理收到的APNS消息,向服务器上报收到APNS消息
|
||||
|
||||
// 下面的接口是可选的
|
||||
// 设置标签和(或)别名(若参数为nil,则忽略;若是空对象,则清空;详情请参考文档:http://docs.jpush.cn/pages/viewpage.action?pageId=3309913)
|
||||
+ (void)setTags:(NSSet *)tags alias:(NSString *)alias DEPRECATED_ATTRIBUTE;
|
||||
+ (void)setTags:(NSSet *)tags alias:(NSString *)alias callbackSelector:(SEL)cbSelector target:(id)theTarget;
|
||||
+ (void)setTags:(NSSet *)tags alias:(NSString *)alias callbackSelector:(SEL)cbSelector object:(id)theTarget;
|
||||
+ (void)setTags:(NSSet *)tags callbackSelector:(SEL)cbSelector object:(id)theTarget;
|
||||
+ (void)setAlias:(NSString *)alias callbackSelector:(SEL)cbSelector object:(id)theTarget;
|
||||
+ (void)setTags:(NSSet *)tags
|
||||
alias:(NSString *)alias
|
||||
callbackSelector:(SEL)cbSelector
|
||||
target:(id)theTarget;
|
||||
+ (void)setTags:(NSSet *)tags
|
||||
alias:(NSString *)alias
|
||||
callbackSelector:(SEL)cbSelector
|
||||
object:(id)theTarget;
|
||||
+ (void)setTags:(NSSet *)tags
|
||||
callbackSelector:(SEL)cbSelector
|
||||
object:(id)theTarget;
|
||||
+ (void)setAlias:(NSString *)alias
|
||||
callbackSelector:(SEL)cbSelector
|
||||
object:(id)theTarget;
|
||||
// 用于过滤出正确可用的tags,如果总数量超出最大限制则返回最大数量的靠前的可用tags
|
||||
+ (NSSet*)filterValidTags:(NSSet*)tags;
|
||||
+ (NSSet *)filterValidTags:(NSSet *)tags;
|
||||
|
||||
+ (NSString *)openUDID; // UDID
|
||||
/**
|
||||
* 记录页面停留时间功能。
|
||||
* startLogPageView和stopLogPageView为自动计算停留时间
|
||||
* beginLogPageView为手动自己输入停留时间
|
||||
*
|
||||
* @param pageName 页面名称
|
||||
* @param seconds 页面停留时间
|
||||
*/
|
||||
+ (void)startLogPageView:(NSString *)pageName;
|
||||
+ (void)stopLogPageView:(NSString *)pageName;
|
||||
+ (void)beginLogPageView:(NSString *)pageName duration:(int)seconds;
|
||||
|
||||
/**
|
||||
* get the UDID
|
||||
*/
|
||||
+ (NSString *)openUDID DEPRECATED_ATTRIBUTE; // UDID
|
||||
|
||||
/**
|
||||
* get RegistionID
|
||||
*/
|
||||
+ (NSString *)registrionID;
|
||||
@end
|
||||
|
Binary file not shown.
@ -3,7 +3,7 @@ var JPushPlugin = function(){
|
||||
|
||||
};
|
||||
JPushPlugin.prototype.call_native = function ( name, args) {
|
||||
console.log("JPushPlugin.call_native:"+name);
|
||||
|
||||
ret = cordova.exec(null,
|
||||
null,
|
||||
'JPushPlugin',
|
||||
@ -11,9 +11,9 @@ JPushPlugin.prototype.call_native = function ( name, args) {
|
||||
args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setTagsWithAlias = function (tags,alias) {
|
||||
|
||||
console.log("JPushPlugin:setTagsWithAlias");
|
||||
if(tags==null){
|
||||
this.setAlias(alias);
|
||||
return;
|
||||
@ -28,7 +28,6 @@ JPushPlugin.prototype.setTagsWithAlias = function (tags,alias) {
|
||||
}
|
||||
JPushPlugin.prototype.setTags = function (data) {
|
||||
|
||||
console.log("JPushPlugin:setTags");
|
||||
try{
|
||||
this.call_native("setTags", [data]);
|
||||
}
|
||||
@ -38,7 +37,6 @@ JPushPlugin.prototype.setTags = function (data) {
|
||||
}
|
||||
JPushPlugin.prototype.setAlias = function (data) {
|
||||
|
||||
console.log("JPushPlugin:setAlias");
|
||||
try{
|
||||
|
||||
this.call_native("setAlias", [data]);
|
||||
@ -54,7 +52,7 @@ JPushPlugin.prototype.pushCallback = function (data) {
|
||||
var code = bToObj.resultCode;
|
||||
var tags = bToObj.resultTags;
|
||||
var alias = bToObj.resultAlias;
|
||||
console.log("JPushPlugin:callBack--code is "+code+" tags is "+tags + " alias is "+alias);
|
||||
|
||||
}
|
||||
catch(exception){
|
||||
alert(exception);
|
||||
|
Loading…
Reference in New Issue
Block a user