mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-01 00:00:20 +08:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e66336f670 | ||
|
|
2797bdd0e7 | ||
|
|
a197975d03 | ||
|
|
27c4fe7b26 | ||
|
|
aae9e8314a | ||
|
|
7d489c7f20 | ||
|
|
c3cfa01e60 | ||
|
|
27ebdd6809 | ||
|
|
e945bcf53d | ||
|
|
cc858c2464 | ||
|
|
1b93f5e026 | ||
|
|
46e0c1879c | ||
|
|
fe7c52f2c9 | ||
|
|
f217eda463 | ||
|
|
95fc690dd3 | ||
|
|
260c298f6b | ||
|
|
7c1c29a7ec | ||
|
|
0aed054039 | ||
|
|
b018a2748c | ||
|
|
39b7987b25 | ||
|
|
2c3bd5ab38 | ||
|
|
3e23fb9129 | ||
|
|
495497f3ac | ||
|
|
ca72c5eba1 | ||
|
|
4e687db4d3 | ||
|
|
3d74b92952 | ||
|
|
5a33f0c6e2 | ||
|
|
f80c4ca59c | ||
|
|
da08b93e43 | ||
|
|
9279611fcd | ||
|
|
3aec197d1d | ||
|
|
abd2a5bac9 | ||
|
|
95194695fe | ||
|
|
360cdd4c95 | ||
|
|
9fbd45c7c7 | ||
|
|
894c2f902d | ||
|
|
70e2d6d9e2 | ||
|
|
ae42986fc9 | ||
|
|
1b2ffe13d8 | ||
|
|
1b0c64f235 | ||
|
|
219ae72758 | ||
|
|
9536989082 | ||
|
|
b1e00baeb8 | ||
|
|
e24a929ed3 | ||
|
|
2610f4ea9e | ||
|
|
aa53b5a214 | ||
|
|
acaff1c403 | ||
|
|
288253169a | ||
|
|
95587f9379 | ||
|
|
0eda4d42df | ||
|
|
206efc7b2c | ||
|
|
5c671fadc9 | ||
|
|
904384d8ae | ||
|
|
4215437bd6 | ||
|
|
8db89c9f2e | ||
|
|
992246235d | ||
|
|
8e0fee7276 | ||
|
|
734077536b | ||
|
|
bce9508ec5 | ||
|
|
ea685713db | ||
|
|
4c810fcaa9 | ||
|
|
213e5b7bb1 | ||
|
|
1af99fe4bf | ||
|
|
3e55f6f2c4 | ||
|
|
ec40fd3e58 | ||
|
|
e6819f54e2 | ||
|
|
386d1282e9 | ||
|
|
d55a46c54c | ||
|
|
bfe0a76ae0 | ||
|
|
7cc3239e1b | ||
|
|
34857a1eea |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<script type="text/javascript" src="cordova.js"></script>
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var onDeviceReady = function(){
|
var onDeviceReady = function(){
|
||||||
console.log("Device ready!")
|
console.log("JPushPlugin:Device ready!")
|
||||||
initiateUI();
|
initiateUI();
|
||||||
}
|
}
|
||||||
var onTagsWithAlias = function(event){
|
var onTagsWithAlias = function(event){
|
||||||
@@ -26,9 +26,30 @@
|
|||||||
console.log(exception)
|
console.log(exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var onOpenNotification = function(event){
|
||||||
|
try{
|
||||||
|
var alert = event.alert;
|
||||||
|
var extras = event.extras;
|
||||||
|
console.log(alert);
|
||||||
|
//console.log(extras);
|
||||||
|
}
|
||||||
|
catch(exeption){
|
||||||
|
console.log(exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var onReceiveNotification = function(event){
|
||||||
|
try{
|
||||||
|
var alert = event.aps.alert;
|
||||||
|
console.log("JPushPlugin:onReceiveNotification key aps.alert:"+alert);
|
||||||
|
}
|
||||||
|
catch(exeption){
|
||||||
|
console.log(exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var onGetRegistradionID = function(data) {
|
var onGetRegistradionID = function(data) {
|
||||||
try{
|
try{
|
||||||
console.log("index.registrationID:"+data)
|
console.log("JPushPlugin:registrationID is "+data)
|
||||||
|
|
||||||
$("#registrationid").html(data);
|
$("#registrationid").html(data);
|
||||||
}
|
}
|
||||||
@@ -38,9 +59,20 @@
|
|||||||
}
|
}
|
||||||
var initiateUI = function(){
|
var initiateUI = function(){
|
||||||
|
|
||||||
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
try{
|
||||||
|
window.plugins.jPushPlugin.init();
|
||||||
|
window.plugins.jPushPlugin.setDebugMode(true);
|
||||||
|
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
||||||
|
// var extras={"name":"json"};
|
||||||
|
// window.plugins.jPushPlugin.addLocalNotification(1,"hh","ln",1111,1000*60,extras);
|
||||||
|
// window.plugins.jPushPlugin.removeLocalNotification(1111);
|
||||||
|
// window.plugins.jPushPlugin.clearLocalNotifications();
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
|
||||||
//test android interface
|
//test android interface
|
||||||
//window.plugins.jPushPlugin.getNotification(onNotification);
|
|
||||||
//window.plugins.jPushPlugin.stopPush()
|
//window.plugins.jPushPlugin.stopPush()
|
||||||
//window.plugins.jPushPlugin.resumePush();
|
//window.plugins.jPushPlugin.resumePush();
|
||||||
//window.plugins.jPushPlugin.clearAllNoticication();
|
//window.plugins.jPushPlugin.clearAllNoticication();
|
||||||
@@ -48,7 +80,7 @@
|
|||||||
//window.plugins.jPushPlugin.stopPush();
|
//window.plugins.jPushPlugin.stopPush();
|
||||||
//window.plugins.jPushPlugin.isPushStopped(onIsPushStopped);
|
//window.plugins.jPushPlugin.isPushStopped(onIsPushStopped);
|
||||||
//window.plugins.jPushPlugin.init();
|
//window.plugins.jPushPlugin.init();
|
||||||
//window.plugins.jPushPlugin.setDebugable(true);
|
//window.plugins.jPushPlugin.setDebugMode(true);
|
||||||
//window.plugins.jPushPlugin.startLogPageView("mianPage");
|
//window.plugins.jPushPlugin.startLogPageView("mianPage");
|
||||||
|
|
||||||
$("#setTagWithAliasButton").click(function(ev) {
|
$("#setTagWithAliasButton").click(function(ev) {
|
||||||
@@ -80,18 +112,16 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
|
||||||
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
|
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
document.addEventListener("deviceready", onDeviceReady, false);
|
||||||
|
document.addEventListener("jpush.openNotification", onOpenNotification, false);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div data-role="page" id="page">
|
<div data-role="page" id="page">
|
||||||
|
|
||||||
<div data-role="header" class="ui-bar ui-bar-b">
|
|
||||||
<center>
|
|
||||||
<img border="0" src="img/logo.png" alt="Urban Airship" align="center" />
|
|
||||||
</center>
|
|
||||||
</div>
|
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
<form>
|
<form>
|
||||||
<div class="ui-body ui-body-b">
|
<div class="ui-body ui-body-b">
|
||||||
|
|||||||
11
plugin.xml
11
plugin.xml
@@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="cn.jpush.phonegap.JPushPlugin"
|
id="cn.jpush.phonegap.JPushPlugin"
|
||||||
version="1.5.3">
|
version="2.0.0">
|
||||||
|
|
||||||
<name>JPush Plugin</name>
|
<name>JPush Plugin</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
||||||
|
|
||||||
<header-file src="src/ios/lib/APService.h" />
|
<header-file src="src/ios/lib/APService.h" />
|
||||||
<source-file src="src/ios/lib/libPushSDK.a" framework="true" />
|
<source-file src="src/ios/lib/libPushSDK-1.8.2.a" framework="true" />
|
||||||
|
|
||||||
<resource-file src="src/ios/PushConfig.plist" />
|
<resource-file src="src/ios/PushConfig.plist" />
|
||||||
|
|
||||||
@@ -153,10 +153,11 @@
|
|||||||
<receiver android:name="cn.jpush.android.service.AlarmReceiver"/>
|
<receiver android:name="cn.jpush.android.service.AlarmReceiver"/>
|
||||||
<!-- Required . Enable it you can get statistics data with channel -->
|
<!-- Required . Enable it you can get statistics data with channel -->
|
||||||
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
||||||
<meta-data android:name="JPUSH_APPKEY" android:value="299d0fee887820e7d90a68b2"/>
|
<meta-data android:name="JPUSH_APPKEY" android:value="your appkey"/>
|
||||||
</config-file>
|
</config-file>
|
||||||
<source-file src="src/android/jpush-sdk-release1.6.1.jar" target-dir="libs"/>
|
<source-file src="src/android/jpush-sdk-release1.7.3.jar" target-dir="libs"/>
|
||||||
<source-file src="src/android/libjpush.so" target-dir="libs/armeabi"/>
|
<source-file src="src/android/armeabi/libjpush173.so" target-dir="libs/armeabi"/>
|
||||||
|
<source-file src="src/android/armeabi-v7a/libjpush173.so" target-dir="libs/armeabi-v7a"/>
|
||||||
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>
|
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>
|
||||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
||||||
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout"/>
|
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout"/>
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ import org.apache.cordova.CordovaWebView;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.thi.pushtest.R;
|
import your.package.name.R;
|
||||||
|
|
||||||
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
||||||
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
||||||
import cn.jpush.android.api.JPushInterface;
|
import cn.jpush.android.api.JPushInterface;
|
||||||
|
import cn.jpush.android.data.JPushLocalNotification;
|
||||||
import cn.jpush.android.api.TagAliasCallback;
|
import cn.jpush.android.api.TagAliasCallback;
|
||||||
|
|
||||||
public class JPushPlugin extends CordovaPlugin {
|
public class JPushPlugin extends CordovaPlugin {
|
||||||
@@ -37,19 +39,25 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
"setCustomPushNotificationBuilder",
|
"setCustomPushNotificationBuilder",
|
||||||
"setPushTime",
|
"setPushTime",
|
||||||
"init",
|
"init",
|
||||||
"setDebugable",
|
"setDebugMode",
|
||||||
"stopPush",
|
"stopPush",
|
||||||
"resumePush",
|
"resumePush",
|
||||||
"isPushStopped",
|
"isPushStopped",
|
||||||
"setLatestNotificationNum",
|
"setLatestNotificationNum",
|
||||||
"setPushTime",
|
"setPushTime",
|
||||||
"clearAllNotification");
|
"clearAllNotification",
|
||||||
|
"addLocalNotification",
|
||||||
|
"removeLocalNotification",
|
||||||
|
"clearLocalNotifications",
|
||||||
|
"onResume",
|
||||||
|
"onPause",
|
||||||
|
"reportNotificationOpened");
|
||||||
|
|
||||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||||
private static JPushPlugin instance;
|
private static JPushPlugin instance;
|
||||||
|
|
||||||
public static String notificationAlert;
|
public static String notificationAlert;
|
||||||
public static Map<String, String> notificationExtras=new HashMap<String, String>();
|
public static Map<String, Object> notificationExtras=new HashMap<String, Object>();
|
||||||
|
|
||||||
public JPushPlugin() {
|
public JPushPlugin() {
|
||||||
instance = this;
|
instance = this;
|
||||||
@@ -58,29 +66,65 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||||
super.initialize(cordova, webView);
|
super.initialize(cordova, webView);
|
||||||
JPushInterface.setDebugMode(true);
|
//JPushInterface.setDebugMode(true);
|
||||||
JPushInterface.init(cordova.getActivity().getApplicationContext());
|
//JPushInterface.init(cordova.getActivity().getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static JSONObject notificationObject(String message,
|
private static JSONObject notificationObject(String message,
|
||||||
Map<String, String> extras) {
|
Map<String, Object> extras) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
data.put("message", message);
|
data.put("message", message);
|
||||||
data.put("extras", new JSONObject(extras));
|
JSONObject jExtras = new JSONObject();
|
||||||
|
for(Entry<String,Object> entry:extras.entrySet()){
|
||||||
|
if(entry.getKey().equals("cn.jpush.android.EXTRA")){
|
||||||
|
JSONObject jo = new JSONObject((String)entry.getValue());
|
||||||
|
jExtras.put("cn.jpush.android.EXTRA", jo);
|
||||||
|
} else {
|
||||||
|
jExtras.put(entry.getKey(),entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(jExtras.length()>0)
|
||||||
|
{
|
||||||
|
data.put("extras", jExtras);
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transmitPush(String message, Map<String, String> extras) {
|
private static JSONObject openNotificationObject(String alert,
|
||||||
|
Map<String, Object> extras){
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
try{
|
||||||
|
data.put("alert", alert);
|
||||||
|
JSONObject jExtras = new JSONObject();
|
||||||
|
for(Entry<String,Object> entry:extras.entrySet()){
|
||||||
|
if(entry.getKey().equals("cn.jpush.android.EXTRA")){
|
||||||
|
JSONObject jo = new JSONObject((String)entry.getValue());
|
||||||
|
jExtras.put("cn.jpush.android.EXTRA", jo);
|
||||||
|
}else{
|
||||||
|
jExtras.put(entry.getKey(),entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(jExtras.length()>0)
|
||||||
|
{
|
||||||
|
data.put("extras", jExtras);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
static void transmitPush(String message, Map<String, Object> extras) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject data = notificationObject(message, extras);
|
JSONObject data = notificationObject(message, extras);
|
||||||
String js = String
|
String js = String
|
||||||
.format("window.plugins.jPushPlugin.pushCallback(%s);",
|
.format("window.plugins.jPushPlugin.receiveMessageInAndroidCallback('%s');",
|
||||||
data.toString());
|
data.toString());
|
||||||
try {
|
try {
|
||||||
instance.webView.sendJavascript(js);
|
instance.webView.sendJavascript(js);
|
||||||
@@ -90,7 +134,27 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void transmitOpen(String alert, Map<String, Object> extras) {
|
||||||
|
if (instance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONObject data = openNotificationObject(alert, extras);
|
||||||
|
String js = String
|
||||||
|
.format("window.plugins.jPushPlugin.openNotificationInAndroidCallback('%s');",
|
||||||
|
data.toString());
|
||||||
|
try {
|
||||||
|
instance.webView.sendJavascript(js);
|
||||||
|
|
||||||
|
String jsEvent=String
|
||||||
|
.format("cordova.fireDocumentEvent('jpush.openNotification',%s)",
|
||||||
|
data.toString());
|
||||||
|
instance.webView.sendJavascript(jsEvent);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final String action, final JSONArray data,
|
public boolean execute(final String action, final JSONArray data,
|
||||||
final CallbackContext callbackContext) throws JSONException {
|
final CallbackContext callbackContext) throws JSONException {
|
||||||
@@ -114,20 +178,21 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
void init(JSONArray data,CallbackContext callbackContext){
|
void init(JSONArray data,CallbackContext callbackContext){
|
||||||
JPushInterface.init(this.cordova.getActivity().getApplicationContext());
|
JPushInterface.init(this.cordova.getActivity().getApplicationContext());
|
||||||
callbackContext.success();
|
//callbackContext.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDebugable(JSONArray data, CallbackContext callbackContext) {
|
void setDebugMode(JSONArray data, CallbackContext callbackContext) {
|
||||||
String mode;
|
boolean mode;
|
||||||
try {
|
try {
|
||||||
mode = data.getString(0);
|
mode = data.getBoolean(0);
|
||||||
if (mode.equals("true")) {
|
// if (mode.equals("true")) {
|
||||||
JPushInterface.setDebugMode(true);
|
// JPushInterface.setDebugMode(true);
|
||||||
} else if (mode.equals("false")) {
|
// } else if (mode.equals("false")) {
|
||||||
JPushInterface.setDebugMode(false);
|
// JPushInterface.setDebugMode(false);
|
||||||
} else {
|
// } else {
|
||||||
callbackContext.error("error mode");
|
// callbackContext.error("error mode");
|
||||||
}
|
// }
|
||||||
|
JPushInterface.setDebugMode(mode);
|
||||||
callbackContext.success();
|
callbackContext.success();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
}
|
}
|
||||||
@@ -147,8 +212,8 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
void isPushStopped(JSONArray data,
|
void isPushStopped(JSONArray data,
|
||||||
CallbackContext callbackContext){
|
CallbackContext callbackContext){
|
||||||
boolean isStoped =JPushInterface.isPushStopped(this.cordova.getActivity().getApplicationContext());
|
boolean isStopped =JPushInterface.isPushStopped(this.cordova.getActivity().getApplicationContext());
|
||||||
if(isStoped){
|
if(isStopped){
|
||||||
callbackContext.success(1);
|
callbackContext.success(1);
|
||||||
}else{
|
}else{
|
||||||
callbackContext.success(0);
|
callbackContext.success(0);
|
||||||
@@ -165,7 +230,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
callbackContext.error("error reading num json");
|
callbackContext.error("error reading num json");
|
||||||
}
|
}
|
||||||
if(num != -1){
|
if(num != -1){
|
||||||
JPushInterface.setLatestNotifactionNumber(this.cordova.getActivity().getApplicationContext(), num);
|
JPushInterface.setLatestNotificationNumber(this.cordova.getActivity().getApplicationContext(), num);
|
||||||
}else{
|
}else{
|
||||||
callbackContext.error("error num");
|
callbackContext.error("error num");
|
||||||
}
|
}
|
||||||
@@ -174,13 +239,13 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
void setPushTime(JSONArray data,
|
void setPushTime(JSONArray data,
|
||||||
CallbackContext callbackContext){
|
CallbackContext callbackContext){
|
||||||
Set<Integer> days = new HashSet<Integer>();
|
Set<Integer> days = new HashSet<Integer>();
|
||||||
JSONArray dayArr;
|
JSONArray dayArray;
|
||||||
int startHour = -1;
|
int startHour = -1;
|
||||||
int endHour = -1;
|
int endHour = -1;
|
||||||
try {
|
try {
|
||||||
dayArr = data.getJSONArray(0);
|
dayArray = data.getJSONArray(0);
|
||||||
for (int i = 0; i < dayArr.length(); i++) {
|
for (int i = 0; i < dayArray.length(); i++) {
|
||||||
days.add(dayArr.getInt(i));
|
days.add(dayArray.getInt(i));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -200,6 +265,23 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
String regID= JPushInterface.getRegistrationID(this.cordova.getActivity().getApplicationContext());
|
String regID= JPushInterface.getRegistrationID(this.cordova.getActivity().getApplicationContext());
|
||||||
callbackContext.success(regID);
|
callbackContext.success(regID);
|
||||||
|
|
||||||
|
}
|
||||||
|
void onResume(JSONArray data, CallbackContext callbackContext) {
|
||||||
|
JPushInterface.onResume(this.cordova.getActivity());
|
||||||
|
}
|
||||||
|
void onPause(JSONArray data, CallbackContext callbackContext) {
|
||||||
|
JPushInterface.onPause(this.cordova.getActivity());
|
||||||
|
}
|
||||||
|
void reportNotificationOpened(JSONArray data, CallbackContext callbackContext) {
|
||||||
|
try {
|
||||||
|
String msgID;
|
||||||
|
msgID = data.getString(0);
|
||||||
|
JPushInterface.reportNotificationOpened(this.cordova.getActivity(),msgID);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void setTags(JSONArray data, CallbackContext callbackContext) {
|
void setTags(JSONArray data, CallbackContext callbackContext) {
|
||||||
|
|
||||||
@@ -212,8 +294,11 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
tags= new HashSet<String>();
|
tags= new HashSet<String>();
|
||||||
}else{
|
}else{
|
||||||
tagStr = data.getString(0);
|
tagStr = data.getString(0);
|
||||||
String[] tagArr = tagStr.split(",");
|
String[] tagArray = tagStr.split(",");
|
||||||
for (String tag : tagArr) {
|
for (String tag : tagArray) {
|
||||||
|
if(tags==null){
|
||||||
|
tags= new HashSet<String>();
|
||||||
|
}
|
||||||
tags.add(tag);
|
tags.add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,9 +329,9 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
String alias;
|
String alias;
|
||||||
try {
|
try {
|
||||||
alias = data.getString(0);
|
alias = data.getString(0);
|
||||||
JSONArray tagsArr = data.getJSONArray(1);
|
JSONArray tagsArray = data.getJSONArray(1);
|
||||||
for (int i = 0; i < tagsArr.length(); i++) {
|
for (int i = 0; i < tagsArray.length(); i++) {
|
||||||
tags.add(tagsArr.getString(i));
|
tags.add(tagsArray.getString(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.setAliasAndTags(this.cordova.getActivity()
|
JPushInterface.setAliasAndTags(this.cordova.getActivity()
|
||||||
@@ -258,23 +343,23 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getNotification(JSONArray data, CallbackContext callBackContext) {
|
// void getNotification(JSONArray data, CallbackContext callBackContext) {
|
||||||
String alert = JPushPlugin.notificationAlert;
|
// String alert = JPushPlugin.notificationAlert;
|
||||||
Map<String, String> extras = JPushPlugin.notificationExtras;
|
// Map<String, String> extras = JPushPlugin.notificationExtras;
|
||||||
|
//
|
||||||
JSONObject jsonData = new JSONObject();
|
// JSONObject jsonData = new JSONObject();
|
||||||
try {
|
// try {
|
||||||
jsonData.put("message", alert);
|
// jsonData.put("message", alert);
|
||||||
jsonData.put("extras", new JSONObject(extras));
|
// jsonData.put("extras", new JSONObject(extras));
|
||||||
} catch (JSONException e) {
|
// } catch (JSONException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
callBackContext.success(jsonData);
|
// callBackContext.success(jsonData);
|
||||||
|
//
|
||||||
JPushPlugin.notificationAlert = "";
|
// JPushPlugin.notificationAlert = "";
|
||||||
JPushPlugin.notificationExtras = new HashMap<String, String>();
|
// JPushPlugin.notificationExtras = new HashMap<String, Obl>();
|
||||||
}
|
// }
|
||||||
|
|
||||||
void setBasicPushNotificationBuilder(JSONArray data,
|
void setBasicPushNotificationBuilder(JSONArray data,
|
||||||
CallbackContext callbackContext) {
|
CallbackContext callbackContext) {
|
||||||
@@ -288,7 +373,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
callbackContext.success(obj);
|
//callbackContext.success(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCustomPushNotificationBuilder(JSONArray data,
|
void setCustomPushNotificationBuilder(JSONArray data,
|
||||||
@@ -305,13 +390,13 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
callbackContext.success(obj);
|
//callbackContext.success(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAllNotification(JSONArray data,
|
void clearAllNotification(JSONArray data,
|
||||||
CallbackContext callbackContext){
|
CallbackContext callbackContext){
|
||||||
JPushInterface.clearAllNotifications(this.cordova.getActivity());
|
JPushInterface.clearAllNotifications(this.cordova.getActivity());
|
||||||
callbackContext.success();
|
//callbackContext.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearNotificationById(JSONArray data,
|
void clearNotificationById(JSONArray data,
|
||||||
@@ -329,6 +414,41 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
callbackContext.error("error id");
|
callbackContext.error("error id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void addLocalNotification(JSONArray data,
|
||||||
|
CallbackContext callbackContext) throws JSONException{
|
||||||
|
//builderId,content,title,notificaitonID,broadcastTime,extras
|
||||||
|
|
||||||
|
int builderId=data.getInt(0);
|
||||||
|
String content =data.getString(1);
|
||||||
|
String title = data.getString(2);
|
||||||
|
int notificationID= data.getInt(3);
|
||||||
|
int broadcastTime=data.getInt(4);
|
||||||
|
JSONObject extras=data.getJSONObject(5);
|
||||||
|
|
||||||
|
JPushLocalNotification ln = new JPushLocalNotification();
|
||||||
|
ln.setBuilderId(builderId);
|
||||||
|
ln.setContent(content);
|
||||||
|
ln.setTitle(title);
|
||||||
|
ln.setNotificationId(notificationID) ;
|
||||||
|
ln.setBroadcastTime(System.currentTimeMillis() + broadcastTime);
|
||||||
|
|
||||||
|
ln.setExtras(extras.toString()) ;
|
||||||
|
JPushInterface.addLocalNotification(this.cordova.getActivity(), ln);
|
||||||
|
|
||||||
|
}
|
||||||
|
void removeLocalNotification(JSONArray data,
|
||||||
|
CallbackContext callbackContext) throws JSONException{
|
||||||
|
|
||||||
|
int notificationID=data.getInt(0);
|
||||||
|
JPushInterface.removeLocalNotification(this.cordova.getActivity(),notificationID);
|
||||||
|
|
||||||
|
}
|
||||||
|
void clearLocalNotifications(JSONArray data,
|
||||||
|
CallbackContext callbackContext){
|
||||||
|
|
||||||
|
JPushInterface.clearLocalNotifications(this.cordova.getActivity());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private final TagAliasCallback mTagWithAliasCallback = new TagAliasCallback() {
|
private final TagAliasCallback mTagWithAliasCallback = new TagAliasCallback() {
|
||||||
|
|
||||||
@@ -348,10 +468,6 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
.format("cordova.fireDocumentEvent('jpush.setTagsWithAlias',%s)",
|
.format("cordova.fireDocumentEvent('jpush.setTagsWithAlias',%s)",
|
||||||
data.toString());
|
data.toString());
|
||||||
instance.webView.sendJavascript(jsEvent);
|
instance.webView.sendJavascript(jsEvent);
|
||||||
String js = String
|
|
||||||
.format("window.plugins.jPushPlugin.pushCallback('%s');",
|
|
||||||
data.toString());
|
|
||||||
instance.webView.sendJavascript(js);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ public class MyReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
private void handlingReceivedMessage(Intent intent) {
|
private void handlingReceivedMessage(Intent intent) {
|
||||||
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
|
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
|
||||||
Map<String,String> extras = getNotificationExtras(intent);
|
Map<String,Object> extras = getNotificationExtras(intent);
|
||||||
|
|
||||||
JPushPlugin.transmitPush(msg, extras);
|
JPushPlugin.transmitPush(msg, extras);
|
||||||
}
|
}
|
||||||
private void handlingNotificationOpen(Context context,Intent intent){
|
private void handlingNotificationOpen(Context context,Intent intent){
|
||||||
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
||||||
Map<String,String> extras = getNotificationExtras(intent);
|
Map<String,Object> extras = getNotificationExtras(intent);
|
||||||
|
|
||||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
@@ -50,19 +50,25 @@ public class MyReceiver extends BroadcastReceiver {
|
|||||||
JPushPlugin.notificationAlert = alert;
|
JPushPlugin.notificationAlert = alert;
|
||||||
JPushPlugin.notificationExtras = extras;
|
JPushPlugin.notificationExtras = extras;
|
||||||
|
|
||||||
|
JPushPlugin.transmitOpen(alert, extras);
|
||||||
|
|
||||||
context.startActivity(launch);
|
context.startActivity(launch);
|
||||||
}
|
}
|
||||||
private Map<String, String> getNotificationExtras(Intent intent) {
|
private Map<String, Object> getNotificationExtras(Intent intent) {
|
||||||
Map<String, String> extrasMap = new HashMap<String, String>();
|
Map<String, Object> extrasMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
for (String key : intent.getExtras().keySet()) {
|
for (String key : intent.getExtras().keySet()) {
|
||||||
if (!IGNORED_EXTRAS_KEYS.contains(key)) {
|
if (!IGNORED_EXTRAS_KEYS.contains(key)) {
|
||||||
Log.e("key","key:"+key);
|
Log.e("key","key:"+key);
|
||||||
extrasMap.put(key, intent.getStringExtra(key));
|
if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)){
|
||||||
|
extrasMap.put(key, intent.getIntExtra(key,0));
|
||||||
|
}else{
|
||||||
|
extrasMap.put(key, intent.getStringExtra(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return extrasMap;
|
return extrasMap;
|
||||||
}
|
}
|
||||||
private static final List<String> IGNORED_EXTRAS_KEYS =
|
private static final List<String> IGNORED_EXTRAS_KEYS =
|
||||||
Arrays.asList("cn.jpush.android.TITLE","cn.jpush.android.MESSAGE","cn.jpush.android.APPKEY");
|
Arrays.asList("cn.jpush.android.TITLE","cn.jpush.android.MESSAGE","cn.jpush.android.APPKEY","cn.jpush.android.NOTIFICATION_CONTENT_TITLE");
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/android/armeabi-v7a/libjpush173.so
Normal file
BIN
src/android/armeabi-v7a/libjpush173.so
Normal file
Binary file not shown.
BIN
src/android/armeabi/libjpush173.so
Normal file
BIN
src/android/armeabi/libjpush173.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/jpush-sdk-release1.7.3.jar
Normal file
BIN
src/android/jpush-sdk-release1.7.3.jar
Normal file
Binary file not shown.
Binary file not shown.
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#import <Cordova/CDV.h>
|
#import <Cordova/CDV.h>
|
||||||
|
|
||||||
|
#define kJPushPluginReceiveNotification @"JPushPluginReceiveNofication"
|
||||||
|
|
||||||
@interface JPushPlugin : CDVPlugin{
|
@interface JPushPlugin : CDVPlugin{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,30 @@
|
|||||||
|
|
||||||
@implementation JPushPlugin
|
@implementation JPushPlugin
|
||||||
|
|
||||||
|
- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView{
|
||||||
|
if (self=[super initWithWebView:theWebView]) {
|
||||||
|
|
||||||
|
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
|
||||||
|
[defaultCenter addObserver:self
|
||||||
|
selector:@selector(networkDidReceiveMessage:)
|
||||||
|
name:kJPFNetworkDidReceiveMessageNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
[defaultCenter addObserver:self
|
||||||
|
selector:@selector(networkDidReceiveNotification:)
|
||||||
|
name:kJPushPluginReceiveNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
||||||
|
|
||||||
NSArray *arguments=command.arguments;
|
NSArray *arguments=command.arguments;
|
||||||
if (!arguments||[arguments count]<2) {
|
if (!arguments||[arguments count]<2) {
|
||||||
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",@""]];
|
// [self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",@""]];
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
NSString *alias=[arguments objectAtIndex:0];
|
NSString *alias=[arguments objectAtIndex:0];
|
||||||
@@ -51,8 +70,8 @@
|
|||||||
|
|
||||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
||||||
|
|
||||||
NSString* registratonID = [APService registrionID];
|
NSString* registrationID = [APService registrationID];
|
||||||
CDVPluginResult *result=[self pluginResultForValue:registratonID];
|
CDVPluginResult *result=[self pluginResultForValue:registrationID];
|
||||||
if (result) {
|
if (result) {
|
||||||
[self succeedWithPluginResult:result withCallbackID:command.callbackId];
|
[self succeedWithPluginResult:result withCallbackID:command.callbackId];
|
||||||
} else {
|
} else {
|
||||||
@@ -78,7 +97,7 @@
|
|||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",jsonString]];
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",jsonString]];
|
||||||
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
|
// [self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -106,7 +125,44 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
-(void)beginLogPageView:(CDVInvokedUrlCommand*)command{
|
||||||
|
NSArray *arguments=command.arguments;
|
||||||
|
if (!arguments||[arguments count]<2) {
|
||||||
|
NSLog(@"beginLogPageView argument error");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
NSString * pageName=[arguments objectAtIndex:0];
|
||||||
|
int duration=[[arguments objectAtIndex:0]intValue];
|
||||||
|
if (pageName) {
|
||||||
|
[APService beginLogPageView:pageName duration:duration];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
-(void)setBadge:(CDVInvokedUrlCommand*)command{
|
||||||
|
NSArray *argument=command.arguments;
|
||||||
|
if ([argument count]<1) {
|
||||||
|
NSLog(@"setBadge argument error!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSNumber *badge=[argument objectAtIndex:0];
|
||||||
|
[APService setBadge:[badge intValue]];
|
||||||
|
}
|
||||||
|
-(void)resetBadge:(CDVInvokedUrlCommand*)command{
|
||||||
|
[APService resetBadge];
|
||||||
|
}
|
||||||
|
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command{
|
||||||
|
|
||||||
|
[APService setDebugMode];
|
||||||
|
}
|
||||||
|
-(void)setLogOFF:(CDVInvokedUrlCommand*)command{
|
||||||
|
|
||||||
|
[APService setLogOFF];
|
||||||
|
}
|
||||||
|
-(void)stopPush:(CDVInvokedUrlCommand*)command{
|
||||||
|
|
||||||
|
[[UIApplication sharedApplication]unregisterForRemoteNotifications];
|
||||||
|
|
||||||
|
}
|
||||||
- (void)failWithCallbackID:(NSString *)callbackID {
|
- (void)failWithCallbackID:(NSString *)callbackID {
|
||||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
||||||
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
|
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
|
||||||
@@ -141,5 +197,38 @@
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
||||||
|
|
||||||
|
NSDictionary *userInfo = [notification userInfo];
|
||||||
|
//NSLog(@"%@",userInfo);
|
||||||
|
|
||||||
|
NSError *error;
|
||||||
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||||
|
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
|
//NSLog(@"%@",jsonString);
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
|
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.receiveMessageIniOSCallback('%@')",jsonString]];
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)networkDidReceiveNotification:(id)notification{
|
||||||
|
|
||||||
|
NSError *error;
|
||||||
|
NSDictionary *userInfo = [notification object];
|
||||||
|
|
||||||
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||||
|
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -4,23 +4,27 @@
|
|||||||
//
|
//
|
||||||
// Created by JPush on 12-8-15.
|
// Created by JPush on 12-8-15.
|
||||||
// Copyright (c) 2012年 HXHG. All rights reserved.
|
// Copyright (c) 2012年 HXHG. All rights reserved.
|
||||||
// Version: 1.7.1
|
// Version: 1.8.2
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
@class CLRegion;
|
||||||
|
@class UILocalNotification;
|
||||||
|
|
||||||
extern NSString *const kAPNetworkDidSetupNotification; // 建立连接
|
extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接
|
||||||
extern NSString *const kAPNetworkDidCloseNotification; // 关闭连接
|
extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接
|
||||||
extern NSString *const kAPNetworkDidRegisterNotification; // 注册成功
|
extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功
|
||||||
extern NSString *const kAPNetworkDidLoginNotification; // 登录成功
|
extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功
|
||||||
extern NSString *const
|
extern NSString *const
|
||||||
kAPNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
|
kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
|
||||||
extern NSString *const kAPServiceErrorNotification; // 错误提示
|
extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
||||||
|
|
||||||
|
@class CLLocation;
|
||||||
@interface APService : NSObject
|
@interface APService : NSObject
|
||||||
|
|
||||||
|
#pragma - mark 基本功能
|
||||||
// 以下四个接口是必须调用的
|
// 以下四个接口是必须调用的
|
||||||
+ (void)setupWithOption:(NSDictionary *)launchingOption; // 初始化
|
+ (void)setupWithOption:(NSDictionary *)launchingOption; // 初始化
|
||||||
+ (void)registerForRemoteNotificationTypes:(int)types; // 注册APNS类型
|
+ (void)registerForRemoteNotificationTypes:(NSUInteger)types
|
||||||
|
categories:(NSSet *)categories; // 注册APNS类型
|
||||||
+ (void)registerDeviceToken:(NSData *)deviceToken; // 向服务器上报Device Token
|
+ (void)registerDeviceToken:(NSData *)deviceToken; // 向服务器上报Device Token
|
||||||
+ (void)handleRemoteNotification:(NSDictionary *)
|
+ (void)handleRemoteNotification:(NSDictionary *)
|
||||||
remoteInfo; // 处理收到的APNS消息,向服务器上报收到APNS消息
|
remoteInfo; // 处理收到的APNS消息,向服务器上报收到APNS消息
|
||||||
@@ -44,6 +48,7 @@ extern NSString *const kAPServiceErrorNotification; // 错误提示
|
|||||||
// 用于过滤出正确可用的tags,如果总数量超出最大限制则返回最大数量的靠前的可用tags
|
// 用于过滤出正确可用的tags,如果总数量超出最大限制则返回最大数量的靠前的可用tags
|
||||||
+ (NSSet *)filterValidTags:(NSSet *)tags;
|
+ (NSSet *)filterValidTags:(NSSet *)tags;
|
||||||
|
|
||||||
|
#pragma - mark 上报日志
|
||||||
/**
|
/**
|
||||||
* 记录页面停留时间功能。
|
* 记录页面停留时间功能。
|
||||||
* startLogPageView和stopLogPageView为自动计算停留时间
|
* startLogPageView和stopLogPageView为自动计算停留时间
|
||||||
@@ -56,13 +61,121 @@ extern NSString *const kAPServiceErrorNotification; // 错误提示
|
|||||||
+ (void)stopLogPageView:(NSString *)pageName;
|
+ (void)stopLogPageView:(NSString *)pageName;
|
||||||
+ (void)beginLogPageView:(NSString *)pageName duration:(int)seconds;
|
+ (void)beginLogPageView:(NSString *)pageName duration:(int)seconds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启Crash日志收集, 默认是关闭状态.
|
||||||
|
*/
|
||||||
|
+ (void)crashLogON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地理位置设置
|
||||||
|
* 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
|
||||||
|
* 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
|
||||||
|
* @param latitude 纬度.
|
||||||
|
* @param longitude 经度.
|
||||||
|
* @param location 直接传递CLLocation *型的地理信息
|
||||||
|
*/
|
||||||
|
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
|
||||||
|
+ (void)setLocation:(CLLocation *)location;
|
||||||
|
|
||||||
|
#pragma - mark 本地通知
|
||||||
|
/**
|
||||||
|
* 本地推送,最多支持64个
|
||||||
|
* @param fireDate 本地推送触发的时间
|
||||||
|
* @param alertBody 本地推送需要显示的内容
|
||||||
|
* @param badge 角标的数字。如果不需要改变角标传-1
|
||||||
|
* @param alertAction 弹框的按钮显示的内容(IOS 8默认为"打开",其他默认为"启动")
|
||||||
|
* @param notificationKey 本地推送标示符
|
||||||
|
* @param userInfo 自定义参数,可以用来标识推送和增加附加信息
|
||||||
|
* @param soundName 自定义通知声音,设置为nil为默认声音
|
||||||
|
|
||||||
|
* IOS8新参数
|
||||||
|
* @param region 自定义参数
|
||||||
|
* @param regionTriggersOnce 自定义参数
|
||||||
|
* @param category 自定义参数
|
||||||
|
*/
|
||||||
|
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
|
||||||
|
alertBody:(NSString *)alertBody
|
||||||
|
badge:(int)badge
|
||||||
|
alertAction:(NSString *)alertAction
|
||||||
|
identifierKey:(NSString *)notificationKey
|
||||||
|
userInfo:(NSDictionary *)userInfo
|
||||||
|
soundName:(NSString *)soundName;
|
||||||
|
|
||||||
|
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
|
||||||
|
alertBody:(NSString *)alertBody
|
||||||
|
badge:(int)badge
|
||||||
|
alertAction:(NSString *)alertAction
|
||||||
|
identifierKey:(NSString *)notificationKey
|
||||||
|
userInfo:(NSDictionary *)userInfo
|
||||||
|
soundName:(NSString *)soundName
|
||||||
|
region:(CLRegion *)region
|
||||||
|
regionTriggersOnce:(BOOL)regionTriggersOnce
|
||||||
|
category:(NSString *)category
|
||||||
|
NS_AVAILABLE_IOS(8_0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地推送在前台推送。默认App在前台运行时不会进行弹窗,在程序接收通知调用此接口可实现指定的推送弹窗。
|
||||||
|
* @param notification 本地推送对象
|
||||||
|
* @param notificationKey 需要前台显示的本地推送通知的标示符
|
||||||
|
*/
|
||||||
|
+ (void)showLocalNotificationAtFront:(UILocalNotification *)notification
|
||||||
|
identifierKey:(NSString *)notificationKey;
|
||||||
|
/**
|
||||||
|
* 删除本地推送
|
||||||
|
* @param notificationKey 本地推送标示符
|
||||||
|
* @param myUILocalNotification 本地推送对象
|
||||||
|
*/
|
||||||
|
+ (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey;
|
||||||
|
+ (void)deleteLocalNotification:(UILocalNotification *)localNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定通知
|
||||||
|
* @param notificationKey 本地推送标示符
|
||||||
|
* @return 本地推送对象数组,[array count]为0时表示没找到
|
||||||
|
*/
|
||||||
|
+ (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除所有本地推送对象
|
||||||
|
*/
|
||||||
|
+ (void)clearAllLocalNotifications;
|
||||||
|
|
||||||
|
#pragma - mark 设置Badge
|
||||||
|
/**
|
||||||
|
* set setBadge
|
||||||
|
* @param value 设置JPush服务器的badge的值
|
||||||
|
* 本地仍须调用UIApplication:setApplicationIconBadgeNumber函数,来设置脚标
|
||||||
|
*/
|
||||||
|
+ (BOOL)setBadge:(NSInteger)value;
|
||||||
|
/**
|
||||||
|
* set setBadge
|
||||||
|
* @param value 清除JPush服务器对badge值的设定.
|
||||||
|
* 本地仍须调用UIApplication:setApplicationIconBadgeNumber函数,来设置脚标
|
||||||
|
*/
|
||||||
|
|
||||||
|
+ (void)resetBadge;
|
||||||
|
|
||||||
|
#pragma - mark 获取用户标示符
|
||||||
/**
|
/**
|
||||||
* get the UDID
|
* get the UDID
|
||||||
*/
|
*/
|
||||||
+ (NSString *)openUDID DEPRECATED_ATTRIBUTE; // UDID
|
+ (NSString *)openUDID DEPRECATED_ATTRIBUTE; // UDID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get RegistionID
|
* get RegistrationID
|
||||||
*/
|
*/
|
||||||
+ (NSString *)registrionID;
|
+ (NSString *)registrationID;
|
||||||
|
|
||||||
|
#pragma - mark 打印日志信息配置
|
||||||
|
/**
|
||||||
|
* setDebugMode获取更多的Log信息
|
||||||
|
* 开发过程中建议开启DebugMode
|
||||||
|
*
|
||||||
|
* setLogOFF关闭除了错误信息外的所有Log
|
||||||
|
* 发布时建议开启LogOFF用于节省性能开销
|
||||||
|
*
|
||||||
|
* 默认为不开启DebugLog,只显示基本的信息
|
||||||
|
*/
|
||||||
|
+ (void)setDebugMode;
|
||||||
|
+ (void)setLogOFF;
|
||||||
@end
|
@end
|
||||||
|
|||||||
BIN
src/ios/lib/libPushSDK-1.8.2.a
Normal file
BIN
src/ios/lib/libPushSDK-1.8.2.a
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
var JPushPlugin = function(){
|
var JPushPlugin = function(){
|
||||||
};
|
};
|
||||||
|
//private plugin function
|
||||||
|
|
||||||
JPushPlugin.prototype.isPlatformIOS = function(){
|
JPushPlugin.prototype.isPlatformIOS = function(){
|
||||||
return device.platform == "iPhone" || device.platform == "iPad" || device.platform == "iPod touch" || device.platform == "iOS"
|
return device.platform == "iPhone" || device.platform == "iPad" || device.platform == "iPod touch" || device.platform == "iOS"
|
||||||
@@ -14,16 +16,23 @@ JPushPlugin.prototype.call_native = function(name, args, callback){
|
|||||||
ret = cordova.exec(callback,this.error_callback,'JPushPlugin',name,args);
|
ret = cordova.exec(callback,this.error_callback,'JPushPlugin',name,args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
//public plugin function
|
||||||
|
|
||||||
JPushPlugin.prototype.startLogPageView = function(data){
|
JPushPlugin.prototype.startLogPageView = function(pageName){
|
||||||
if(this.isPlatformIOS()){
|
if(this.isPlatformIOS()){
|
||||||
this.call_native( "startLogPageView",[data],null);
|
this.call_native( "startLogPageView",[pageName],null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.stopLogPageView = function(data){
|
JPushPlugin.prototype.stopLogPageView = function(pageName){
|
||||||
if(this.isPlatformIOS()){
|
if(this.isPlatformIOS()){
|
||||||
this.call_native( "stopLogPageView",[data],null);
|
this.call_native( "stopLogPageView",[pageName],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.beginLogPageView = function(pageName,duration){
|
||||||
|
if(this.isPlatformIOS()){
|
||||||
|
this.call_native( "beginLogPageView",[pageName,duration],null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +55,24 @@ JPushPlugin.prototype.setTagsWithAlias = function(tags,alias){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
JPushPlugin.prototype.setTags = function(tags){
|
||||||
|
|
||||||
|
try{
|
||||||
|
this.call_native("setTags",tags,null);
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.setAlias = function(alias){
|
||||||
|
try{
|
||||||
|
this.call_native("setAlias",[alias],null);
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
JPushPlugin.prototype.getRegistrationID = function(callback){
|
JPushPlugin.prototype.getRegistrationID = function(callback){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -57,33 +83,90 @@ JPushPlugin.prototype.getRegistrationID = function(callback){
|
|||||||
console.log(exception);
|
console.log(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JPushPlugin.prototype.setTags = function(data){
|
|
||||||
|
JPushPlugin.prototype.setBadge = function(value){
|
||||||
try{
|
|
||||||
this.call_native("setTags",data,null);
|
if(this.isPlatformIOS()){
|
||||||
|
try{
|
||||||
|
this.call_native("setBadge",[value],null);
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.resetBadge = function(){
|
||||||
|
|
||||||
|
if(this.isPlatformIOS()){
|
||||||
|
try{
|
||||||
|
var data=[];
|
||||||
|
this.call_native("resetBadge",[data],null);
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.setDebugModeFromIos = function(){
|
||||||
|
if(this.isPlatformIOS()){
|
||||||
|
var data=[];
|
||||||
|
this.call_native("setDebugModeFromIos",[data],null);
|
||||||
}
|
}
|
||||||
catch(exception){
|
|
||||||
console.log(exception);
|
}
|
||||||
|
JPushPlugin.prototype.setLogOFF = function(){
|
||||||
|
if(this.isPlatformIOS()){
|
||||||
|
var data=[];
|
||||||
|
this.call_native("setLogOFF",[data],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.receiveMessageIniOSCallback = function(data){
|
||||||
|
try{
|
||||||
|
console.log("JPushPlugin:receiveMessageIniOSCallback--data:"+data);
|
||||||
|
var bToObj = JSON.parse(data);
|
||||||
|
var content = bToObj.content;
|
||||||
|
console.log(content);
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log("JPushPlugin:receiveMessageIniOSCallback"+exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data){
|
||||||
|
try{
|
||||||
|
console.log("JPushPlugin:receiveMessageInAndroidCallback");
|
||||||
|
//console.log(data);
|
||||||
|
//ecvar bToObj=JSON.parse(data);
|
||||||
|
//var message = bToObj.message;
|
||||||
|
//var extras = bToObj.extras;
|
||||||
|
|
||||||
|
//console.log(message);
|
||||||
|
//console.log(extras['cn.jpush.android.MSG_ID']);
|
||||||
|
//console.log(extras['cn.jpush.android.CONTENT_TYPE']);
|
||||||
|
//console.log(extras['cn.jpush.android.EXTRA']);
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log("JPushPlugin:pushCallback "+exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setAlias = function(data){
|
//
|
||||||
try{
|
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data){
|
||||||
this.call_native("setAlias",[data],null);
|
|
||||||
}
|
|
||||||
catch(exception){
|
|
||||||
console.log(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.pushCallback = function(data){
|
|
||||||
try{
|
try{
|
||||||
|
console.log("JPushPlugin:openNotificationInAndroidCallback");
|
||||||
console.log(data);
|
console.log(data);
|
||||||
var bToObj=JSON.parse(data);
|
//var bToObj = JSON.parse(data);
|
||||||
var code = bToObj.resultCode;
|
//var alert = bToObj.alert;
|
||||||
var tags = bToObj.resultTags;
|
//var extras = bToObj.extras;
|
||||||
var alias = bToObj.resultAlias;
|
//console.log(alert);
|
||||||
console.log("JPushPlugin:callBack--code is "+code+" tags is "+tags + " alias is "+alias);
|
|
||||||
|
//console.log(extras['cn.jpush.android.MSG_ID']);
|
||||||
|
//console.log(extras['app']);
|
||||||
|
//console.log(extras['cn.jpush.android.NOTIFICATION_CONTENT_TITLE']);
|
||||||
|
//console.log(extras['cn.jpush.android.EXTRA']);
|
||||||
|
//console.log(extras['cn.jpush.android.PUSH_ID']);
|
||||||
|
//console.log(extras['cn.jpush.android.NOTIFICATION_ID']);
|
||||||
|
//console.log("JPushPlugin:openNotificationCallback is ready");
|
||||||
}
|
}
|
||||||
catch(exception){
|
catch(exception){
|
||||||
console.log(exception);
|
console.log(exception);
|
||||||
@@ -91,13 +174,6 @@ JPushPlugin.prototype.pushCallback = function(data){
|
|||||||
}
|
}
|
||||||
//android single
|
//android single
|
||||||
|
|
||||||
JPushPlugin.prototype.getNotification = function (callback) {
|
|
||||||
if(device.platform == "Android") {
|
|
||||||
data=[];
|
|
||||||
this.call_native("getNotification",data,callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setBasicPushNotificationBuilder = function(){
|
JPushPlugin.prototype.setBasicPushNotificationBuilder = function(){
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
data=[]
|
data=[]
|
||||||
@@ -113,10 +189,8 @@ JPushPlugin.prototype.setCustomPushNotificationBuilder = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.stopPush = function(){
|
JPushPlugin.prototype.stopPush = function(){
|
||||||
if(device.platform == "Android") {
|
data=[];
|
||||||
data=[];
|
this.call_native("stopPush",data,null);
|
||||||
this.call_native("stopPush",data,null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.resumePush = function(){
|
JPushPlugin.prototype.resumePush = function(){
|
||||||
@@ -125,8 +199,13 @@ JPushPlugin.prototype.resumePush = function(){
|
|||||||
this.call_native("resumePush",data,null);
|
this.call_native("resumePush",data,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
JPushPlugin.prototype.setDebugMode = function(mode){
|
||||||
JPushPlugin.prototype.clearAllNoticication = function(){
|
if(device.platform == "Android") {
|
||||||
|
this.call_native("setDebugMode",[mode],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//setDebugMode
|
||||||
|
JPushPlugin.prototype.clearAllNotification = function(){
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
data=[]
|
data=[]
|
||||||
this.call_native("clearAllNotification",data,null);
|
this.call_native("clearAllNotification",data,null);
|
||||||
@@ -153,13 +232,49 @@ JPushPlugin.prototype.init = function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setDebugable = function(mode){
|
JPushPlugin.prototype.setDebugMode = function(mode){
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
this.call_native("setDebugable",[mode],null);
|
this.call_native("setDebugMode",[mode],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.addLocalNotification = function(builderId,content,title,notificaitonID,broadcastTime,extras){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[builderId,content,title,notificaitonID,broadcastTime,extras];
|
||||||
|
this.call_native("addLocalNotification",data,null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.removeLocalNotification = function(notificationID){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
this.call_native("removeLocalNotification",[notificationID],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.clearLocalNotifications = function(){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[]
|
||||||
|
this.call_native("clearLocalNotifications",data,null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.onResume = function(){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[]
|
||||||
|
this.call_native("onResume",data,null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.onPause = function(){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[]
|
||||||
|
this.call_native("onPause",data,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ios single
|
JPushPlugin.prototype.reportNotificationOpened = function(msgID){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
|
||||||
|
this.call_native("reportNotificationOpened",[msgID],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//iOS single
|
||||||
|
|
||||||
|
|
||||||
if(!window.plugins){
|
if(!window.plugins){
|
||||||
|
|||||||
Reference in New Issue
Block a user