gpt4 book ai didi

android - Urban Airship Android GCM 未在 Android Oreo 和 Pie 上接收推送通知

转载 作者:行者123 更新时间:2023-11-29 00:58:18 25 4
gpt4 key购买 nike

刚刚将应用程序更新为 API 27,并将 com.urbanairship.android:urbanairship-gcm:9.1.0 添加到 build.gradle 文件中。我可以在 Android N 及以下版本上接收推送通知,但在 Android O 及更高版本上尝试时不起作用,我已经为通知分配了一个 channel ,但它仍然不起作用这里是 AutoPilot 的代码:

public class UrbanAirshipAutoPilot extends AutoPilot {

@Override
public void onAirshipReady(@NonNull UAirship airship) {
airship.getPushManager().setUserNotificationsEnabled(true);

// Android O
if (Build.VERSION.SDK_INT >= 26) {
Context context = UAirship.getApplicationContext();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

NotificationChannel channel = new NotificationChannel(UAConstants.DEFAULT_CHANNEL,
context.getString(R.string.custom_channel_name,
NotificationManager.IMPORTANCE_DEFAULT);

notificationManager.createNotificationChannel(channel);
}
airship.getPushManager().setPushEnabled(true);
airship.getPushManager().setUserNotificationsEnabled(true);

}

@Override
public AirshipConfigOptions createAirshipConfigOptions(@NonNull Context context) {
AirshipConfigOptions options = new AirshipConfigOptions.Builder()
.setDevelopmentAppKey(UAConstants.DEV_PROD_KEY)
.setDevelopmentAppSecret(UAConstants.DEV_SECRET_KEY)
.setProductionAppKey(UAConstants.PROD_APP_KEY)
.setProductionAppSecret(UAConstants.PROD_SECRET_KEY)
.setFcmSenderId(UAConstants.GCM_PROJECT_ID)
.setNotificationIcon(R.drawable.ic_notification)
.setNotificationAccentColor(ContextCompat(getContext(), R.color.accent))
.setNotificationChannel(UAConstants.DEFAULT_CHANNEL)
.build();

return options;
}
}

我还将 AutoPilot 添加到 Manifest,它被调用它似乎在任何 Android 版本上都能正常工作和初始化,但由于某种原因,Android O 上没有收到通知。

此外,我们目前仍在使用 GCM

最佳答案

我们发现 Urban Airship 和 GCM 存在同样的问题。我们现在已经在 Urban Airship 中使用 Firebase 进行了测试,现在通知似乎可以正常工作。

因为其他相关问题,例如here ,我想问题不在于 Urban Airship,而是在 Android 中,GCM 只是有问题,并且不会得到修复,因为它已被弃用。

关于android - Urban Airship Android GCM 未在 Android Oreo 和 Pie 上接收推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52977114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com