增加极光推送
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:exported="true"
|
||||
@@ -67,6 +68,20 @@
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<service
|
||||
android:name=".service.DialerAccessibilityService"
|
||||
android:exported="true"
|
||||
android:label="@string/accessibility_service_label"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<!-- android:priority="10000" 可提高服务在设置中的权重,排在前面 -->
|
||||
<intent-filter android:priority="10000">
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/accessibility_service_config" />
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
android:name=".receiver.AppChangedReceiver"
|
||||
android:enabled="true"
|
||||
@@ -94,19 +109,32 @@
|
||||
android:name="com.baidu.location.f"
|
||||
android:enabled="true"
|
||||
android:process=":remote" />
|
||||
|
||||
<!--(jpush|jad)_config_start,jpush和jad公用的组件-->
|
||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||
<!--User defined. For test only 继承自cn.jpush.android.service.JCommonService-->
|
||||
<service
|
||||
android:name=".service.DialerAccessibilityService"
|
||||
android:exported="true"
|
||||
android:label="@string/accessibility_service_label"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<!-- android:priority="10000" 可提高服务在设置中的权重,排在前面 -->
|
||||
<intent-filter android:priority="10000">
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
android:name=".push.jpush.JpushService"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:process=":pushcore">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jiguang.user.service.action" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/accessibility_service_config" />
|
||||
</service>
|
||||
<!--(jpush|jad)_config_end-->
|
||||
|
||||
|
||||
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
|
||||
<!--since 5.2.0 接收JPush相关事件-->
|
||||
<receiver
|
||||
android:name=".push.jpush.PushMessageService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.SERVICE_MESSAGE" />
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<meta-data
|
||||
android:name="com.baidu.lbsapi.API_KEY"
|
||||
|
||||
@@ -19,6 +19,10 @@ import com.ttstd.dialer.manager.AppManager;
|
||||
import com.ttstd.dialer.utils.SystemUtils;
|
||||
import com.ttstd.iconloader.IconCacheManager;
|
||||
|
||||
import cn.jiguang.api.JCoreInterface;
|
||||
import cn.jiguang.api.utils.JCollectionAuth;
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = "BaseApplication";
|
||||
@@ -54,6 +58,26 @@ public class BaseApplication extends Application {
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
|
||||
/*jpush start*/
|
||||
JPushInterface.setDebugMode(true);
|
||||
// 调整点一:调用启用推送业务功能代码前增加setAuth调用
|
||||
boolean isPrivacyReady = true; // app根据是否已弹窗获取隐私授权来赋值
|
||||
if (!isPrivacyReady) {
|
||||
// JCore 5.0.4之前版本需要显式设置false
|
||||
if (JCoreInterface.getJCoreSDKVersionInt() < 504) { // 5.0.4版本号对应504
|
||||
JCollectionAuth.setAuth(context, false);
|
||||
}
|
||||
// 所有版本在未授权时都不应初始化SDK
|
||||
return;
|
||||
}
|
||||
JPushInterface.init(this);
|
||||
JPushInterface.setAlias(this, );
|
||||
|
||||
// 调整点二:App用户同意了隐私政策授权,并且开发者确定要开启推送服务后调用
|
||||
// JCore 5.0.4+会自动处理授权状态,可不需要显式设置true
|
||||
JCollectionAuth.setAuth(context, true);
|
||||
/*jpush end*/
|
||||
|
||||
HeConfig.init(BuildConfig.QweatherId, BuildConfig.QweatherKey);
|
||||
//切换至免费订阅
|
||||
HeConfig.switchToDevService();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ttstd.dialer.push.jpush;
|
||||
|
||||
import cn.jpush.android.service.JCommonService;
|
||||
|
||||
public class JpushService extends JCommonService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ttstd.dialer.push.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import cn.jpush.android.api.CustomMessage;
|
||||
import cn.jpush.android.api.JPushMessage;
|
||||
import cn.jpush.android.service.JPushMessageReceiver;
|
||||
|
||||
public class PushMessageService extends JPushMessageReceiver {
|
||||
|
||||
@Override
|
||||
public void onMessage(Context context, CustomMessage customMessage) {
|
||||
super.onMessage(context, customMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
super.onAliasOperatorResult(context, jPushMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user