Just updated the app to API 27 and added com.urbanairship.android:urbanairship-gcm:9.1.0 to build.gradle file. I can receive push notifications on Android N and below but doesn't work when triying on Android O and above, I already assigned a channel to notifications but it still not works here's what the code for AutoPilot looks like:
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;
}
}
I also added the AutoPilot to Manifest and it gets called it seems to be working and initializing correctly on any android version but for some reason notification don't arrive on Android O.
Also we are still using GCM at the moment