0

I'm adding Urban Airship push notifications to my Android app. My custom BroadcastReceiver is receiving the notifications when I send a test push. Here's the onReceive() method.

public class IntentReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent == null)
            return;

    String action = intent.getAction();

    if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
        int id = intent.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, 0); //Breakpoint here

        Log.w("my app", "Received push notification. Alert: "
                + intent.getStringExtra(PushManager.EXTRA_ALERT)
                + " [NotificationID="+id+"]");

        logPushExtras(intent);

    } else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
        //Other stuff here
    }

Execution stops at the breakpoint (position shown in the comment) and the details are logged.

No notification is shown in the notification area though. In my other app with UA push notifications, I think this was all I did, but it doesn't seem to be working this time.

I suspect I've done something wrong in my manifest file or that I've forgotten to implement a class somewhere.

Any ideas?

Extra Info

Extended Application:

public class ExtendedApplication extends Application {

    public void onCreate(){
        AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
        UAirship.takeOff(this, options);
        PushManager.enablePush();

        PushPreferences prefs = PushManager.shared().getPreferences();
        Log.e("my app", "My Application onCreate - App APID: " + prefs.getPushId());

        PushManager.shared().setIntentReceiver(IntentReceiver.class);
    }
}

Edit

I've tried adding

PushManager.shared().setNotificationBuilder(new BasicPushNotificationBuilder());

to my ExtendedApplication as suggested in this post.

Community
  • 1
  • 1
Mike T
  • 4,747
  • 4
  • 32
  • 52

1 Answers1

0

I was sending a test push with a blank "Alert" field from the UA site. I tried with some text in there and now it works. I don't know why, but I don't think that's something that should fail silently.

Moral of the story: Don't leave your Alert field blank.

Mike T
  • 4,747
  • 4
  • 32
  • 52