Я включил push-уведомления, используя городской дирижабль, но получаю уведомления только при перемещении приложения из фона в передний план.
Метод onPushReceived () никогда не вызывается в следующем получателе
class UrbanAirshipReceiver : AirshipReceiver() {
override fun onPushReceived(context: Context, message: PushMessage, notificationPosted: Boolean) {
LocalBroadcastManager.getInstance(context).sendBroadcast(Intent(Constants.INBOX_MESSAGE_RECEIVED))
}
}
AndroidManifext.xml
<meta-data
android:name="com.urbanairship.autopilot"
android:value="base.helper.UrbanAirshipHelper" />
<receiver
android:name=".common.receiver.UrbanAirshipReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.urbanairship.push.CHANNEL_UPDATED" />
<action android:name="com.urbanairship.push.OPENED" />
<action android:name="com.urbanairship.push.RECEIVED" />
<action android:name="com.urbanairship.push.DISMISSED" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
Это класс автопилота
class UrbanAirshipHelper : Autopilot() {
override fun onAirshipReady(airship: UAirship?) {
/*Enable Push notification*/
Log.i("SampleAirshipReceiver", "onAirshipReady")
airship?.pushManager?.userNotificationsEnabled = true
// Android O
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val context = UAirship.getApplicationContext()
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val channel = NotificationChannel(Constants.CHANNEL_ID,
Constants.CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT)
notificationManager.createNotificationChannel(channel)
}
}
override fun createAirshipConfigOptions(context: Context): AirshipConfigOptions? {
/*customize your config at runtime:*/
return AirshipConfigOptions.Builder().apply {
setInProduction(false)
setDevelopmentAppKey(DEVELOPMENT_APP_KEY)
setDevelopmentAppSecret(DEVELOPMENT_APP_SECRET)
setFcmSenderId(FCM_SENDER_ID)
setNotificationAccentColor(ContextCompat.getColor(context, R.color.accent))
setNotificationIcon(R.drawable.ic_notification_white)
setNotificationChannel(Constants.CHANNEL_NAME)
}.build()
}
}
Любая помощь будет оценена.