Receiving two notifications in android

Hello,

I receive two notifications in my android app from urban airship

One notification is proper which is received by my customnotification class but the another notification comes from no where.

Pls help me on this.

pls below my settings

 

UAirship.takeOff(this, new UAirship.OnReadyCallback() {
@Override
public void onAirshipReady(UAirship airship) {

// Enable user notifications
airship.getPushManager().setUserNotificationsEnabled(false);

}
});


UAirship.shared().getPushManager().setUserNotificationsEnabled(false);
UAirship.shared().getPushManager().setPushEnabled(true);
UAirship.shared().getPushManager().getRegistrationToken();
UAirship.shared().getPushManager().setNotificationFactory(new CustomPushNotificationFactory(context));
UAirship.shared().getInAppMessageManager().setDisplayAsapEnabled(true);
UAirship.shared().getInAppMessageManager().setAutoDisplayDelay(1000L);

Thanks,
Baps

Didn't find what you were looking for?

New post

Comments

11 comments

  • Hi Baps,

    How have you set up your Custom Push Notification Factory? Are you perhaps posting the notification twice?

    Does it show this same behavior if you use the Default Notification Factory?

     

    Also, which App Key are you sending pushes from?

    Lastly, do you know why you have setUserNotificationsEnabled to false in your code? That needs to be turned on in order for the device to be able to properly receive push notifications. If you are not setting that to true elsewhere in your code, you should consider doing that.

    0
  • Hi Michael,

    I am getting the same issue, receiving two notifications. One from UA & second from FirebaseMessagingService(I have written my own logic there to show notification as per the data.). I am not using Custom Push Notification Factory I have not extended NotificationFactory class in my app. I have extended AirshipReceiver only & not using NotificationManager in it's onPushReceived method.

    I have simply implemented the basic UA to get push from dashboard.

    public class UAirshipAutoPilot extends Autopilot {

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

    @Override
    public AirshipConfigOptions createAirshipConfigOptions(@NonNull Context context) {
    return super.createAirshipConfigOptions(context);
    }
    }

    <meta-data android:name="com.urbanairship.autopilot"
    android:value="com.xyz.UrbanAirship.UAirshipAutoPilot"/>

    Thanks,

    Poras Bhardwaj

    0
  • Poras,

    Just to be clear, the problem you're running into is that you're sending push notifications from both Urban Airship and Firebase, and you only want to show one notification to the user, is that correct?

    Or, is it that you have both Urban Airship and Firebase integrated into your app, and you send one push from Urban Airship, and you appear to receive two pushes on the device?

    0
  • Michael,

    Yes, I have both Urban Airship and Firebase integrated into my App, and when I send one push from Urban Airship dashboard, I receive two pushes on the device. I want one push at a time whether it is from Firebase or Urban Airship.

    0
  • Poras,

    Is there any particular reason/use case as to why you're using Firebase for messaging as well?

    I ask this because Urban Airship will send messages through to Google, which is likely going through Firebase as well. Depending on how you are handling showing the notification to the user, this may appear as two pushes to the user.

    How are you currently displaying the push to the user?

    0
  • Hi Michael,

    I have been using FCM for push notifications before I implemented Urban Airship. In my app pushes triggers from server/backend on certain conditions when user do some action in app. Ex: If User A sends a message to User B then user B will get a notification for that.

    In Android code I extended FirebaseMessagingService to handle these push notifications where I get the payload bundled with these push & creates system notifications on some conditions using NotificationManager.

    Should I stop using FirebaseMessagingService & move the logic in FirebaseMessagingService to AirshipReciever?

    Thanks

    0
  • Poras,

    Yes, I would move your Firebase logic from Firebase to using Urban Airship.

    Urban Airship already delivers notifications to GCM/FCM, and both Urban Airship and Firebase are handling showing the notification to the user.

    Since Urban Airship is handling this, it is redundant to use FirebaseMessagingService to show the message to the user.

    0
  • Hi Michael,

    If I am not wrong, Push notification I am sending from my own server would be handled by FirebaseMessagingService as it is direct communication between my server & FCM(No role of UA). And, notifications from UA would be handled by UA receiver & FirebaseMessaging as UA is also using FCM to send notifications.

    My Server
    SERVER > FCM > APP(FirebaseMessagingService)

    Urban Airship

    UA > FCM > APP(FirebaseMessagingService/AirshipReceiver)

    So, to mange push from my Server I have to use FirebaseMessagingService to handle the push I sent from my server. And, AirshipReceiver to handle push sent from Urban Airship. I have to use both in my app. I can not move logic of FirebaseMessagingService to AirshipReceiver.

    0
  • Poras,

    Your workflow should look more like:

    SERVER> UA > FCM > APP(AirshipReceiver).

    There's no reason why your Server would not be able to send those same messages to UA through our API.

    The problem that you're running into is that both Firebase and UA are handling the same push message, which ends up displaying the message twice to the user. So, your only two options are to either remove UA from your app, or remove your Firebase integration and allow UA to handle showing those messages to your users. Unless there is a special use case from your server, there's no reason UA would not be able to handle those messages.

    0
  • I have same issue while using Firebase and UA together . Any solution for that?

    I am always getting channelID (airship.getPushManager().getChannelId()) null when launch application first time.

     

    Please give me solution of these 2 issues

    0
  • Jane,

    Just to confirm, are you only receiving a null Channel when launching the app the first time?

    Or, does the Channel Id always remain null even after first launch?

    If it's the former, then that is expected and explained in our docs

    "Once a Channel ID is created, it will persist the application until it is either reinstalled, or its internal data is cleared.

    Don't worry if this value initially comes back as null on your app's first run (or after clearing the application data), as the Channel ID will be created and persisted during registration. To receive an event when the Channel ID is created, see Listening for Push Events."

    0

Please sign in to leave a comment.