mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-15 17:02:50 +08:00
Android添加手机号设置接口
This commit is contained in:
parent
10b29611c5
commit
fad4745e01
@ -200,6 +200,16 @@
|
|||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#setMobileNumber").click(function (event) {
|
||||||
|
var number = $("#mobileNumberText").val()
|
||||||
|
window.JPush.setMobileNumber({ sequence: 5, mobileNumber: number },
|
||||||
|
function (result) {
|
||||||
|
$("#mobileNumberResult").html(result.mobileNumber)
|
||||||
|
}, function (error){
|
||||||
|
alert(error.code)
|
||||||
|
})
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
document.addEventListener("deviceready", onDeviceReady, false);
|
||||||
@ -251,6 +261,14 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<label>MobileNumber: </label>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="text" id="mobileNumberText" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-role="fieldcontain">
|
<div data-role="fieldcontain">
|
||||||
@ -265,6 +283,10 @@
|
|||||||
<input type="button" id="deleteAlias" value="Delete alias" />
|
<input type="button" id="deleteAlias" value="Delete alias" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-role="fieldcontain">
|
||||||
|
<input type="button" id="setMobileNumber" value="Set mobileNumber" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div data-role="fieldcontain">
|
<div data-role="fieldcontain">
|
||||||
<label id="tagsPrompt">设置 Tag 的结果:</label>
|
<label id="tagsPrompt">设置 Tag 的结果:</label>
|
||||||
<label id="tagsResult">null</label>
|
<label id="tagsResult">null</label>
|
||||||
@ -273,6 +295,10 @@
|
|||||||
<label id="aliasPrompt">设置 Alias 的结果:</label>
|
<label id="aliasPrompt">设置 Alias 的结果:</label>
|
||||||
<label id="aliasResult">null</label>
|
<label id="aliasResult">null</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div data-role="fieldcontain">
|
||||||
|
<label id="mobileNumberPrompt">设置手机号的结果:</label>
|
||||||
|
<label id="mobileNumberResult">null</label>
|
||||||
|
</div>
|
||||||
<div data-role="fieldcontain">
|
<div data-role="fieldcontain">
|
||||||
<label id="notificationPrompt">接受的通知内容:</label>
|
<label id="notificationPrompt">接受的通知内容:</label>
|
||||||
<label id="notificationResult">null</label>
|
<label id="notificationResult">null</label>
|
||||||
|
46
src/android/JLogger.java
Normal file
46
src/android/JLogger.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package cn.jiguang.cordova.push;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class JLogger {
|
||||||
|
|
||||||
|
public static final String TAG = "[Cordova-JPush]";
|
||||||
|
|
||||||
|
private static boolean isLoggerEnable = false;
|
||||||
|
|
||||||
|
public static void setLoggerEnable(boolean loggerEnable) {
|
||||||
|
Log.d(TAG, "setLoggerEnable:" + loggerEnable);
|
||||||
|
isLoggerEnable = loggerEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void i(String tag,String msg) {
|
||||||
|
if (isLoggerEnable) {
|
||||||
|
Log.i(TAG+tag, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void d(String tag,String msg) {
|
||||||
|
if (isLoggerEnable) {
|
||||||
|
Log.d(TAG+tag, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void v(String tag,String msg) {
|
||||||
|
if (isLoggerEnable) {
|
||||||
|
Log.v(TAG+tag, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void w(String tag,String msg) {
|
||||||
|
if (isLoggerEnable) {
|
||||||
|
Log.w(TAG+tag, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void e(String tag,String error) {
|
||||||
|
if (isLoggerEnable) {
|
||||||
|
Log.e(TAG+tag, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,20 +3,18 @@ package cn.jiguang.cordova.push;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.apache.cordova.CallbackContext;
|
import org.apache.cordova.CallbackContext;
|
||||||
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;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import cn.jpush.android.api.CustomMessage;
|
import cn.jpush.android.api.CustomMessage;
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import cn.jpush.android.api.JPushMessage;
|
import cn.jpush.android.api.JPushMessage;
|
||||||
import cn.jpush.android.api.NotificationMessage;
|
import cn.jpush.android.api.NotificationMessage;
|
||||||
|
import cn.jpush.android.helper.Logger;
|
||||||
import cn.jpush.android.service.JPushMessageReceiver;
|
import cn.jpush.android.service.JPushMessageReceiver;
|
||||||
|
|
||||||
public class JPushEventReceiver extends JPushMessageReceiver {
|
public class JPushEventReceiver extends JPushMessageReceiver {
|
||||||
@ -26,143 +24,58 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
super.onTagOperatorResult(context, jPushMessage);
|
super.onTagOperatorResult(context, jPushMessage);
|
||||||
//Log.e(TAG,"onTagOperatorResult:"+jPushMessage);
|
JLogger.d(TAG,"onTagOperatorResult:"+jPushMessage);
|
||||||
JSONObject resultJson = new JSONObject();
|
|
||||||
|
|
||||||
int sequence = jPushMessage.getSequence();
|
tryCallback(jPushMessage, new SuccessCallback() {
|
||||||
try {
|
@Override
|
||||||
resultJson.put("sequence", sequence);
|
public void onSuccessCallback(JSONObject resultJson) throws JSONException {
|
||||||
} catch (JSONException e) {
|
Set<String> tags = jPushMessage.getTags();
|
||||||
e.printStackTrace();
|
JSONArray tagsJsonArr = new JSONArray();
|
||||||
}
|
for (String tag : tags) {
|
||||||
|
tagsJsonArr.put(tag);
|
||||||
CallbackContext callback = JPushPlugin.eventCallbackMap.get(sequence);
|
}
|
||||||
|
|
||||||
if (callback == null) {
|
|
||||||
Log.i(TAG, "Unexpected error, callback is null!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jPushMessage.getErrorCode() == 0) { // success
|
|
||||||
Set<String> tags = jPushMessage.getTags();
|
|
||||||
JSONArray tagsJsonArr = new JSONArray();
|
|
||||||
for (String tag : tags) {
|
|
||||||
tagsJsonArr.put(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (tagsJsonArr.length() != 0) {
|
if (tagsJsonArr.length() != 0) {
|
||||||
resultJson.put("tags", tagsJsonArr);
|
resultJson.put("tags", tagsJsonArr);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
callback.success(resultJson);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
resultJson.put("code", jPushMessage.getErrorCode());
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
callback.error(resultJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.eventCallbackMap.remove(sequence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
super.onCheckTagOperatorResult(context, jPushMessage);
|
super.onCheckTagOperatorResult(context, jPushMessage);
|
||||||
|
|
||||||
//Log.e(TAG,"onCheckTagOperatorResult:"+jPushMessage);
|
JLogger.d(TAG,"onCheckTagOperatorResult:"+jPushMessage);
|
||||||
JSONObject resultJson = new JSONObject();
|
|
||||||
|
|
||||||
int sequence = jPushMessage.getSequence();
|
tryCallback(jPushMessage, new SuccessCallback() {
|
||||||
try {
|
@Override
|
||||||
resultJson.put("sequence", sequence);
|
public void onSuccessCallback(JSONObject resultJson) throws JSONException {
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
CallbackContext callback = JPushPlugin.eventCallbackMap.get(sequence);
|
|
||||||
|
|
||||||
if (callback == null) {
|
|
||||||
Log.i(TAG, "Unexpected error, callback is null!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jPushMessage.getErrorCode() == 0) {
|
|
||||||
try {
|
|
||||||
resultJson.put("tag", jPushMessage.getCheckTag());
|
resultJson.put("tag", jPushMessage.getCheckTag());
|
||||||
resultJson.put("isBind", jPushMessage.getTagCheckStateResult());
|
resultJson.put("isBind", jPushMessage.getTagCheckStateResult());
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
callback.success(resultJson);
|
});
|
||||||
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
resultJson.put("code", jPushMessage.getErrorCode());
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
callback.error(resultJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.eventCallbackMap.remove(sequence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
super.onAliasOperatorResult(context, jPushMessage);
|
super.onAliasOperatorResult(context, jPushMessage);
|
||||||
|
|
||||||
//Log.e(TAG,"onAliasOperatorResult:"+jPushMessage);
|
JLogger.d(TAG,"onAliasOperatorResult:"+jPushMessage);
|
||||||
JSONObject resultJson = new JSONObject();
|
|
||||||
|
|
||||||
int sequence = jPushMessage.getSequence();
|
tryCallback(jPushMessage, new SuccessCallback() {
|
||||||
try {
|
@Override
|
||||||
resultJson.put("sequence", sequence);
|
public void onSuccessCallback(JSONObject resultJson) throws JSONException {
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
CallbackContext callback = JPushPlugin.eventCallbackMap.get(sequence);
|
|
||||||
|
|
||||||
if (callback == null) {
|
|
||||||
Log.i(TAG, "Unexpected error, callback is null!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jPushMessage.getErrorCode() == 0) { // success
|
|
||||||
try {
|
|
||||||
if (!TextUtils.isEmpty(jPushMessage.getAlias())) {
|
if (!TextUtils.isEmpty(jPushMessage.getAlias())) {
|
||||||
resultJson.put("alias", jPushMessage.getAlias());
|
resultJson.put("alias", jPushMessage.getAlias());
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
callback.success(resultJson);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
resultJson.put("code", jPushMessage.getErrorCode());
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
callback.error(resultJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.eventCallbackMap.remove(sequence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegister(Context context, String regId) {
|
public void onRegister(Context context, String regId) {
|
||||||
//Log.e(TAG,"onRegister:"+regId);
|
JLogger.d(TAG,"onRegister:"+regId);
|
||||||
JPushPlugin.transmitReceiveRegistrationId(regId);
|
JPushPlugin.transmitReceiveRegistrationId(regId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,24 +92,74 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
|||||||
public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) {
|
public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) {
|
||||||
super.onNotifyMessageArrived(context, notificationMessage);
|
super.onNotifyMessageArrived(context, notificationMessage);
|
||||||
|
|
||||||
//Log.e(TAG,"onNotifyMessageArrived:"+notificationMessage);
|
JLogger.d(TAG,"onNotifyMessageArrived:"+notificationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
|
public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
|
||||||
super.onNotifyMessageOpened(context, notificationMessage);
|
super.onNotifyMessageOpened(context, notificationMessage);
|
||||||
//Log.e(TAG,"onNotifyMessageOpened:"+notificationMessage);
|
JLogger.d(TAG,"onNotifyMessageOpened:"+notificationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
super.onMobileNumberOperatorResult(context, jPushMessage);
|
super.onMobileNumberOperatorResult(context, jPushMessage);
|
||||||
//Log.e(TAG,"onMobileNumberOperatorResult:"+jPushMessage);
|
JLogger.d(TAG,"onMobileNumberOperatorResult:"+jPushMessage);
|
||||||
|
|
||||||
|
tryCallback(jPushMessage, new SuccessCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccessCallback(JSONObject resultJson) throws JSONException {
|
||||||
|
if (!TextUtils.isEmpty(jPushMessage.getMobileNumber())) {
|
||||||
|
resultJson.put("mobileNumber", jPushMessage.getMobileNumber());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMultiActionClicked(Context context, Intent intent) {
|
public void onMultiActionClicked(Context context, Intent intent) {
|
||||||
super.onMultiActionClicked(context, intent);
|
super.onMultiActionClicked(context, intent);
|
||||||
//Log.e(TAG,"onMultiActionClicked:"+intent);
|
JLogger.d(TAG,"onMultiActionClicked:"+intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SuccessCallback{
|
||||||
|
void onSuccessCallback(JSONObject resultJson) throws JSONException;
|
||||||
|
}
|
||||||
|
public void tryCallback(JPushMessage jPushMessage,SuccessCallback successCallback){
|
||||||
|
JSONObject resultJson = new JSONObject();
|
||||||
|
|
||||||
|
int sequence = jPushMessage.getSequence();
|
||||||
|
try {
|
||||||
|
resultJson.put("sequence", sequence);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
CallbackContext callback = JPushPlugin.eventCallbackMap.get(sequence);
|
||||||
|
|
||||||
|
if (callback == null) {
|
||||||
|
Logger.i(TAG, "Unexpected error, callback is null!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jPushMessage.getErrorCode() == 0) {
|
||||||
|
try {
|
||||||
|
successCallback.onSuccessCallback(resultJson);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
callback.success(resultJson);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
resultJson.put("code", jPushMessage.getErrorCode());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
callback.error(resultJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.eventCallbackMap.remove(sequence);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,9 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||||
super.initialize(cordova, webView);
|
super.initialize(cordova, webView);
|
||||||
mContext = cordova.getActivity().getApplicationContext();
|
mContext = cordova.getActivity().getApplicationContext();
|
||||||
|
Log.d(TAG,"initialize plugin");
|
||||||
|
|
||||||
JPushInterface.init(mContext);
|
// JPushInterface.init(mContext);
|
||||||
|
|
||||||
cordovaActivity = cordova.getActivity();
|
cordovaActivity = cordova.getActivity();
|
||||||
|
|
||||||
@ -254,6 +255,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
try {
|
try {
|
||||||
mode = data.getBoolean(0);
|
mode = data.getBoolean(0);
|
||||||
JPushInterface.setDebugMode(mode);
|
JPushInterface.setDebugMode(mode);
|
||||||
|
JLogger.setLoggerEnable(mode);
|
||||||
callbackContext.success();
|
callbackContext.success();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -296,6 +298,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("error reading num json");
|
callbackContext.error("error reading num json");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (num != -1) {
|
if (num != -1) {
|
||||||
JPushInterface.setLatestNotificationNumber(mContext, num);
|
JPushInterface.setLatestNotificationNumber(mContext, num);
|
||||||
@ -364,6 +367,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.setAlias(mContext, sequence, alias);
|
JPushInterface.setAlias(mContext, sequence, alias);
|
||||||
@ -379,6 +383,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.deleteAlias(mContext, sequence);
|
JPushInterface.deleteAlias(mContext, sequence);
|
||||||
@ -394,6 +399,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.getAlias(mContext, sequence);
|
JPushInterface.getAlias(mContext, sequence);
|
||||||
@ -416,6 +422,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.setTags(mContext, sequence, tags);
|
JPushInterface.setTags(mContext, sequence, tags);
|
||||||
@ -438,6 +445,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.addTags(mContext, sequence, tags);
|
JPushInterface.addTags(mContext, sequence, tags);
|
||||||
@ -460,6 +468,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.deleteTags(mContext, sequence, tags);
|
JPushInterface.deleteTags(mContext, sequence, tags);
|
||||||
@ -476,6 +485,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.cleanTags(mContext, sequence);
|
JPushInterface.cleanTags(mContext, sequence);
|
||||||
@ -492,6 +502,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.getAllTags(mContext, sequence);
|
JPushInterface.getAllTags(mContext, sequence);
|
||||||
@ -510,6 +521,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
callbackContext.error("Parameters error.");
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.checkTagBindState(mContext, sequence, tag);
|
JPushInterface.checkTagBindState(mContext, sequence, tag);
|
||||||
@ -642,6 +654,25 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
JPushInterface.setBadgeNumber(mContext, badgeNumb);
|
JPushInterface.setBadgeNumber(mContext, badgeNumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMobileNumber(JSONArray data, CallbackContext callbackContext) throws JSONException {
|
||||||
|
int sequence = -1;
|
||||||
|
String number = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject params = data.getJSONObject(0);
|
||||||
|
sequence = params.getInt("sequence");
|
||||||
|
number = params.getString("mobileNumber");
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
callbackContext.error("Parameters error.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventCallbackMap.put(sequence, callbackContext);
|
||||||
|
JPushInterface.setMobileNumber(mContext,sequence, number);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isValidHour(int hour) {
|
private boolean isValidHour(int hour) {
|
||||||
return !(hour < 0 || hour > 23);
|
return !(hour < 0 || hour > 23);
|
||||||
}
|
}
|
||||||
|
@ -482,6 +482,20 @@ JPushPlugin.prototype.setBadgeNumber = function(badgeNumb) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置手机号。
|
||||||
|
*
|
||||||
|
* @param params = { 'sequence': number, 'mobileNumber': string }
|
||||||
|
*/
|
||||||
|
JPushPlugin.prototype.setMobileNumber = function(
|
||||||
|
params,
|
||||||
|
successCallback,
|
||||||
|
errorCallback
|
||||||
|
) {
|
||||||
|
this.callNative("setMobileNumber", [params], successCallback, errorCallback);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
if (!window.plugins) {
|
if (!window.plugins) {
|
||||||
window.plugins = {};
|
window.plugins = {};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user