build.gradel文件收到我的通知 minifyEnabled错误, 但是只要我们更改了在已签名的发行版APK中未收到的 minifyEnabled true 通知。 这是我的 build.gradel 文件
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.abc.xyz.test"
minSdkVersion 15
targetSdkVersion 28
versionCode 10
versionName "1.0.8"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.brand_champs
}
lintOptions {
disable 'GoogleAppIndexingWarning'
warningsAsErrors true
checkReleaseBuilds false
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
debuggable false
jniDebuggable false
renderscriptDebuggable false
zipAlignEnabled false
}
debug {
debuggable true
zipAlignEnabled false
jniDebuggable false
minifyEnabled false
}
}
}
答案 0 :(得分:0)
要在设备上启用推送通知,必须先在FCM中注册它。这可以通过两种方式完成:您可以让设备直接向Ably注册自己,也可以将注册工作委托给您的应用服务器,然后由应用服务器代表其向Ably注册设备。 一些代码在这里:
import io.ably.lib.realtime.AblyRealtime;
公共类MainActivity扩展了AppCompatActivity {
public static final int SUCCESS = 0;
public static final int FAILURE = 1;
public static final int UPDATE_LOGS = 2;
public static final String STEP_1 = "Initialize Ably";
public static final String STEP_2 = "Activate Push";
public static final String STEP_3 = "Subscribe Channels";
public static final String STEP_4 = "Send Test Push";
public static final String TEST_PUSH_CHANNEL_NAME = "test_push_channel";
//Ensure that ngrok is setup, or modify xml/network_security_config.xml accordingly.
private static final String PRIVATE_SERVER_AUTH_URL = 'YOUR SERVER URL' + "/auth";
private AblyRealtime ablyRealtime;
private String getClientId() {
String clientId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
return clientId;
}
private void initAblyRuntime() throws AblyException {
ClientOptions options = new ClientOptions();
options.environment = BuildConfig.ABLY_ENV;
options.key = BuildConfig.ABLY_KEY;
//Token auth via server
options.authUrl = PRIVATE_SERVER_AUTH_URL;
options.authParams = new Param[]{new Param("clientId", getClientId())};
ablyRealtime = new AblyRealtime(options);
ablyRealtime.setAndroidContext(getApplicationContext());
ablyRealtime.connect();
ablyRealtime.connection.on(new ConnectionStateListener() {
@Override
public void onConnectionStateChanged(ConnectionStateChange state) {
logMessage("Connection state changed to : " + state.current.name());
switch (state.current) {
case connected:
/* Perform device registration and subscription, this is described later in the tutorial */
break;
case disconnected:
case failed:
//handle failure
break;
}
}
});
}
}
如果您发现这很有趣,可以访问this
答案 1 :(得分:0)
朋友们解决了上述问题,
此问题与类迁移或启用proguard时从代码中删除未使用的类有关。
我们将保留规则写入proguard文件中,并保留与通知相关的应用程序的所有模型
-keepclassmembers class com.xyz.test.model.** {
*;
}
这是我的课程模型“ com.xyz.test.model。**”,根据您的ID和软件包名称,您可以使用任何其他课程