diff --git a/README.md b/README.md
index f18e2f1..ff1a25a 100644
--- a/README.md
+++ b/README.md
@@ -189,5 +189,5 @@ https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz/edit#nnzKN
android端sdk引用
```
- implementation "com.farsunset:cim-android-sdk:4.2.11"
+ implementation "com.farsunset:cim-android-sdk:4.2.12"
```
\ No newline at end of file
diff --git a/cim-client-sdk/cim-android-sdk/pom.xml b/cim-client-sdk/cim-android-sdk/pom.xml
index d1dff55..de84791 100755
--- a/cim-client-sdk/cim-android-sdk/pom.xml
+++ b/cim-client-sdk/cim-android-sdk/pom.xml
@@ -6,7 +6,7 @@
com.farsunset
cim-android-sdk
- 4.2.11
+ 4.2.12
jar
${project.groupId}:${project.artifactId}
diff --git a/cim-client-sdk/cim-android-sdk/src/main/java/com/farsunset/cim/sdk/android/CIMPushService.java b/cim-client-sdk/cim-android-sdk/src/main/java/com/farsunset/cim/sdk/android/CIMPushService.java
index 3d5fca2..e7b7a91 100644
--- a/cim-client-sdk/cim-android-sdk/src/main/java/com/farsunset/cim/sdk/android/CIMPushService.java
+++ b/cim-client-sdk/cim-android-sdk/src/main/java/com/farsunset/cim/sdk/android/CIMPushService.java
@@ -26,6 +26,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ServiceInfo;
import android.net.ConnectivityManager;
import android.net.Network;
import android.os.Build;
@@ -69,7 +70,7 @@ public class CIMPushService extends Service {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
keepAliveReceiver = new KeepAliveBroadcastReceiver();
- registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter(),Context.RECEIVER_EXPORTED);
+ registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@@ -111,6 +112,23 @@ public class CIMPushService extends Service {
}
};
+ @Override
+ public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ return super.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter(),Context.RECEIVER_EXPORTED);
+ }else {
+ return super.registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter());
+ }
+ }
+
+ private void startForegroundNotification(int id, Notification notification) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ startForeground(id,notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING);
+ }else {
+ startForeground(id,notification);
+ }
+ }
+
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -260,7 +278,7 @@ public class CIMPushService extends Service {
Notification notification = makeNotification(PERSIST_NTC_CHANNEL_ID,icon,title,message);
- startForeground(NOTIFICATION_ID, notification);
+ startForegroundNotification(NOTIFICATION_ID, notification);
return;
}
@@ -275,7 +293,7 @@ public class CIMPushService extends Service {
Notification notification = makeNotification(TRANSIENT_NTC_CHANNEL_ID,0,CIMPushService.class.getSimpleName(),null);
- startForeground(NOTIFICATION_ID, notification);
+ startForegroundNotification(NOTIFICATION_ID, notification);
}
@@ -297,7 +315,7 @@ public class CIMPushService extends Service {
Notification notification = makeNotification(PERSIST_NTC_CHANNEL_ID,icon,channelName,message);
- startForeground(NOTIFICATION_ID,notification);
+ startForegroundNotification(NOTIFICATION_ID,notification);
}