iOS 更新到6.0.0,安卓更新到6.0.1版本。iOS SDK 换成cocoapods集成,安卓 SDK换成marven集成。插件版本改成6.0.1

This commit is contained in:
huangshuni
2026-01-30 15:08:42 +08:00
parent 43a4917f23
commit 263a372663
26 changed files with 304 additions and 2207 deletions
+12
View File
@@ -15,6 +15,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import cn.jpush.android.api.CmdMessage;
import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.JPushMessage;
@@ -86,6 +87,17 @@ public class JPushEventReceiver extends JPushMessageReceiver {
cn.jiguang.cordova.push.JPushPlugin.transmitReceiveRegistrationId(regId);
}
@Override
public void onCommandResult(Context context, CmdMessage cmdMessage) {
super.onCommandResult(context, cmdMessage);
if (cmdMessage == null) return;
// cmd 2003: getPushStatus / isPushStopped 状态回调。errorCode: 0=未停止, 1=已停止, 其他=异常
if (cmdMessage.cmd == 2003) {
cn.jiguang.cordova.push.JLogger.d(TAG, "[onCommandResult] getPushStatus, errorCode=" + cmdMessage.errorCode);
cn.jiguang.cordova.push.JPushPlugin.onGetPushStatusResult(cmdMessage.errorCode);
}
}
@Override
public void onMessage(Context context, CustomMessage customMessage) {
// super.onMessage(context,customMessage);
+32
View File
@@ -50,6 +50,9 @@ public class JPushPlugin extends CordovaPlugin {
static Map<Integer, CallbackContext> eventCallbackMap = new HashMap<Integer, CallbackContext>();
/** getPushStatus 异步结果通过 JPushMessageReceiver.onCommandResult(cmd==2003) 回调,此处暂存 CallbackContext */
static CallbackContext getPushStatusCallbackContext;
public JPushPlugin() {
instance = this;
}
@@ -329,6 +332,35 @@ public class JPushPlugin extends CordovaPlugin {
}
}
void getPushStatus(JSONArray data, CallbackContext callbackContext) {
getPushStatusCallbackContext = callbackContext;
JPushInterface.getPushStatus(mContext);
// 结果在 JPushEventReceiver.onCommandResult 中当 cmd==2003 时回调
}
/**
* 由 JPushEventReceiver.onCommandResult 在 cmd==2003 时调用,传递 getPushStatus 异步结果。
* 与 iOS 对齐:code=0 表示成功,非 0 表示错误码;isStopped=0 未停止,1 已停止。
* Android errorCode: 0=未停止, 1=已停止, 其他=异常。
*/
static void onGetPushStatusResult(int errorCode) {
if (getPushStatusCallbackContext == null) return;
try {
JSONObject result = new JSONObject();
if (errorCode == 0 || errorCode == 1) {
result.put("code", 0);
result.put("isStopped", errorCode == 1 ? 1 : 0);
} else {
result.put("code", errorCode);
result.put("isStopped", 0);
}
getPushStatusCallbackContext.success(result);
} catch (JSONException e) {
getPushStatusCallbackContext.error("getPushStatus result error");
}
getPushStatusCallbackContext = null;
}
void areNotificationEnabled(JSONArray data, final CallbackContext callback) {
int isEnabled;
if (hasPermission("OP_POST_NOTIFICATION")) {
Binary file not shown.
+2
View File
@@ -52,6 +52,8 @@ static NSMutableDictionary *_jpushEventCache;
-(void)stopPush:(CDVInvokedUrlCommand*)command;
-(void)resumePush:(CDVInvokedUrlCommand*)command;
-(void)isPushStopped:(CDVInvokedUrlCommand*)command;
// 检查推送是否被停止(iOS 6.0.0+ 推荐,替代 isPushStopped
-(void)getPushStatus:(CDVInvokedUrlCommand*)command;
//开关日志
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command;
+12
View File
@@ -48,6 +48,18 @@
[self handleResultWithValue:result command:command];
}
-(void)getPushStatus:(CDVInvokedUrlCommand*)command{
WEAK_SELF(weakSelf)
[JPUSHService getPushStatus:^(NSInteger iResCode, BOOL isStopped) {
NSDictionary *result = @{
@"code": @(iResCode),
@"isStopped": isStopped ? @1 : @0
};
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
-(void)initial:(CDVInvokedUrlCommand*)command{
//do nithng,because Cordova plugin use lazy load mode.
}
@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>libJPush.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>libJPush.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
File diff suppressed because it is too large Load Diff
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
</dict>
</array>
</dict>
</plist>
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
</dict>
</array>
</dict>
</plist>