mirror of
https://gitee.com/farsunset/cim.git
synced 2025-06-17 07:35:25 +08:00
android sdk 适配 android14
This commit is contained in:
parent
6a02c58d4e
commit
cfac26b7ad
@ -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"
|
||||
```
|
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.farsunset</groupId>
|
||||
<artifactId>cim-android-sdk</artifactId>
|
||||
<version>4.2.11</version>
|
||||
<version>4.2.12</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user