cordova-plugin-tpns
v1.0.8
Published
tpns cordova plugin
Downloads
4
Readme
cordova-plugin-tpns
腾讯移动推送 TPNS cordova 插件
支持平台
Android
安装插件
1、通过npm 安装插件
cordova plugin add cordova-plugin-tpns
2、通过本地文件路径安装
cordova plugin add 文件路径
说明: ionic 项目命令前加上ionic,即ionic cordova plugin xxxxx
API接口和使用示例
1、注册
cordova.plugins.TPNSPlugin.registerXG("registerXG",onSuccess,onFail);
2、取消注册
cordova.plugins.TPNSPlugin.unregisterXG("unregisterXG",onSuccess,onFail);
3、开启调试
var params = {
message : "enableDebug",
enableDebug : true
};
cordova.plugins.TPNSPlugin.enableDebug(params,onSuccess,onFail);
4、设置账号
var params = {
message : "setAccount",
accountInfos : [{"account":"elva", "accountType":1002}, {"account":"jay", "accountType":1003}]
};
cordova.plugins.TPNSPlugin.setAccount(params,onSuccess,onFail);
5、删除账号
var params = {
message : "deleteAccount",
accountType : "1003,1002"
};
cordova.plugins.TPNSPlugin.deleteAccount(params,onSuccess,onFail);
6、清除账号
var params = {
message : "clearAccounts",
accountType : "1003,1002"
};
cordova.plugins.TPNSPlugin.clearAccounts(params,onSuccess,onFail);
7、新增标签
var params = {
message : "addTags",
tags : "d,e,f"
};
cordova.plugins.TPNSPlugin.addTags(params,onSuccess,onFail);
8、设置标签
var params = {
message : "setTags",
tags : "a,b,c"
};
cordova.plugins.TPNSPlugin.setTags(params,onSuccess,onFail);
9、清除标签
var params = {
message : "clearTags",
tags : "a,b,c"
};
cordova.plugins.TPNSPlugin.clearTags(params,onSuccess,onFail);
10、开启第三方推送
var params = {
message : "enableOtherPush",
enableOtherPush : true
};
cordova.plugins.TPNSPlugin.enableOtherPush(params,onSuccess,onFail);
11、设置小米推送AppId
var params = {
message : "setMiPushAppId",
appId : "miAppId"
};
cordova.plugins.TPNSPlugin.setMiPushAppId(params,onSuccess,onFail);
12、设置小米推送AppKey
var params = {
message : "setMiPushAppKey",
appId : "miAppKey"
};
cordova.plugins.TPNSPlugin.setMiPushAppKey(params,onSuccess,onFail);
13、设置魅族推送AppId
var params = {
message : "setMzPushAppId",
appId : "mzAppId"
};
cordova.plugins.TPNSPlugin.setMzPushAppId(params,onSuccess,onFail);
14、设置魅族推送AppKey
var params = {
message : "setMzPushAppKey",
appId : "mzAppKey"
};
cordova.plugins.TPNSPlugin.setMzPushAppKey(params,onSuccess,onFail);
15、开启Oppo通知
var params = {
message : "enableOppoNotification",
enableOppoNotification : true
};
cordova.plugins.TPNSPlugin.enableOppoNotification(params,onSuccess,onFail);
16、设置Oppo推送AppId
var params = {
message : "setOppoPushAppId",
appId : "oppoAppId"
};
cordova.plugins.TPNSPlugin.setOppoPushAppId(params,onSuccess,onFail);
17、设置Oppo推送AppKey
var params = {
message : "setOppoPushAppKey",
appId : "oppoAppKey"
};
cordova.plugins.TPNSPlugin.setOppoPushAppKey(params,onSuccess,onFail);
项目AccessID和AccessKey配置
在项目的platforms/android/app/build.gradle文件中配置accessID和AccessKey
android {
defaultConfig {
manifestPlaceholders = [
XG_ACCESS_ID : "1500045345",
XG_ACCESS_KEY : "fgTNBfgSU",
]
}
}
注意事项
由于TPNS包的仓库从jecenter迁移到Maven,为顺利拉取到依赖包,需在app的build.gradle配置文件中allprojects结点下的repositories中配置mavenCentral()仓库。
allprojects {
repositories {
mavenCentral()
}
}