这个都是可以直接看融云文档,我也是按照融云文档接,也没什么好的方法
要提高推送到达率必须接第三方的推送,融云有进一步的封装。
说下注意的点
- 融云后台是分开放环境和生产环境的,内容是否都填了。没有收到推送可以检查下
- 有些oppo和vivo手机是要给通知栏权限的
- 锤子手机是收不到推送的(如果锤子手机收到了推送,记得告诉下我)
下面给下通知栏权限是否已经允许了代码
/**
* desc:询问通知栏是否开启,version>19才访问
* create by cong on 2018/5/5 16:32
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static boolean isNotificationEnabled(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//8.0手机以上
if (((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).getImportance() == NotificationManager.IMPORTANCE_NONE) {
return false;
}
}
String CHECK_OP_NO_THROW = "checkOpNoThrow";
String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION";
AppOpsManager mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
ApplicationInfo appInfo = context.getApplicationInfo();
String pkg = context.getApplicationContext().getPackageName();
int uid = appInfo.uid;
Class appOpsClass = null;
/* Context.APP_OPS_MANAGER */
try {
appOpsClass = Class.forName(AppOpsManager.class.getName());
Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE,
String.class);
Field opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION);
int value = (Integer) opPostNotificationValue.get(Integer.class);
return ((Integer) checkOpNoThrowMethod.invoke(mAppOps, value, uid, pkg) == AppOpsManager.MODE_ALLOWED);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* desc: 跳转到应用程序信息界面,一般用于用户开启通知权限
* Created by congge on 2018/7/18 14:58
**/
public static void startAppDetailSetting(Context mContext) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", mContext.getPackageName(), null));
mContext.startActivity(intent);
}
这篇没什么干货。为了后期可以新增内容。