0
点赞
收藏
分享

微信扫一扫

Android 极光推送快速开发集成指南,想学IT的必看

何晓杰Dev 2022-01-21 阅读 42

<activity

android:name=“cn.jpush.android.ui.PopWinActivity”

android:configChanges=“orientation|keyboardHidden”

android:exported=“false”

android:theme="@style/MyDialogStyle">

<service

android:name=".service.JpushBackgroudeService"

android:enabled=“true”

android:exported=“false”

android:process=":pushcore">

<receiver

android:name=".receiver.PushBackgroudeBrocast"

android:enabled=“true”

android:exported=“false”>

<receiver

android:name=“包名”

android:enabled=“true”

android:exported=“false”>

<activity

android:name=“cn.jpush.android.service.JNotifyActivity”

android:exported=“true”

android:taskAffinity=“jpush.custom”

android:theme="@android:style/Theme.Translucent.NoTitleBar">

在gradle中的

defaultConfig{

ndk {

abiFilters ‘armeabi-v7a’, ‘x86’, ‘x86_64’, ‘armeabi-v7a’//,‘arm64-v8a’

}

manifestPlaceholders = [

JPUSH_PKGNAME: applicationId,

JPUSH_APPKEY : “你的ID”, //JPush 上注册的包名对应的 Appkey.

JPUSH_CHANNEL: “developer-default”, //暂时填写默认值即可.

]

}

这样 配置就算可以了,然后在包下,复制从官网下载的demo,到包里,参考地址:https://docs.jiguang.cn//jpush/client/Android/android_3m/

比如TagAliasOperatorHelper这个工具类 改好以后在全局的Applition中 初始化

JPushInterface.setDebugMode(true);

JPushInterface.init(this);

String registrationID = JPushInterface.getRegistrationID(this);//这个可以传给后台 推送到具体的个人

如上配置好之后:

检查一下有没有通知栏权限

package xxx;

import android.app.AppOpsManager;

import android.content.Context;

import android.content.Intent;

import android.content.pm.ApplicationInfo;

import android.net.Uri;

import android.os.Build;

import android.provider.Settings;

import java.lang.reflect.Field;

import java.lang.reflect.Method;

public class CheckAndStartNitifycationUtils

{

public static boolean isNotificationEnabled(Context context) {

String CHECK_OP_NO_THROW = “checkOpNoThrow”;

String OP_POST_NOTIFICATION = “OP_POST_NOTIFICATION”;

AppOpsManager mAppOps = null;

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {

mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);

}

ApplicationInfo appInfo = context.getApplicationInfo();

String pkg = context.getApplicationContext().getPackageName();

int uid = appInfo.uid;

Class appOpsClass = null;

try {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

appOpsClass = Class.forName(AppOpsManager.class.getName());

}

Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE,

String.class);

etPackageName();

int uid = appInfo.uid;

Class appOpsClass = null;

try {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

appOpsClass = Class.forName(AppOpsManager.class.getName());

}

Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE,

String.class);

举报

相关推荐

0 条评论