Deep link from notifications.

Hi, I'm using Urban Airship SDK for push notifications. For big picture style notifications, I'm extending NotificationFactory, and adding the bitmap to it. Code is as follows (for createNotification method in MyNotificationFactory):

Intent intent = new Intent(mClickAction);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(mClickAction));
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, (int) System.currentTimeMillis() /* Request code */, intent,
PendingIntent.FLAG_UPDATE_CURRENT);

String mImageUrl = pushMessage.getPushBundle().getString("image_url");

mNotificationBitmap = getBitmapFromURL(mImageUrl);

NotificationCompat.BigPictureStyle bigPicStyle = new NotificationCompat.BigPictureStyle();
bigPicStyle.bigLargeIcon(mNotificationBitmap);
bigPicStyle.bigPicture(mNotificationBitmap);
bigPicStyle.setSummaryText("Hi");
bigPicStyle.setBigContentTitle("Great");

NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
.setContentTitle(mContext.getResources().getString(R.string.app_name))
.setContentText("Hey there")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.setAutoCancel(true);

builder.setStyle(bigPicStyle);
return builder.build();

The notification is successfully built, and is posted. On tapping the notification, nothing happens, even if I return false from onNotificationOpened (which should cause UA to launch the launcher activity). I've tried true and false both, but it just hits onNotificationOpened. Need help regarding this.

Didn't find what you were looking for?

New post

Comments

5 comments

  • I had made a silly mistake and the intent action was wrong. Rectified it, and in place of pending intent, constructed the intent in onNotificationOpened and started the activity, and it works fine. But I'm not sure why the pending intent didn't work. Also, notifications don't seem to work when the app has been swiped and closed from the recents list.

    Comment actions Permalink
    0
  • Hi Gaurav,

    Big Picture style is already supported in the NotificationFactory class, so you don't need to rewrite it.

    Instead, you may consider setting your Notification Factory for Urban Airship to use the DefaultNotificationFactory, as this supports it out of the box.

    So, all you would need to do is send the URL for the image you want, and that's all! 

    This should also solve issues with opening the app from the push as well.

    For sending Big Picture and Summary text, you can do so via our API.

     

    Comment actions Permalink
    0
  • Hi Michael,

    Thanks for your reply. As I see, this is indeed possible if I send a style object through an API call. But can you let me know how can I send a 'style' object through console and pass the big_picture or any other field that's needed. I need to get rid of the API and perform all the task from the console. Please guide me on this part.

    Comment actions Permalink
    0
  • Hi, I was able to find the picture option in console (maybe it has been included as a part of new message composer). But I find a few problem areas where I'd seek help.
    1. In device property options, while creating a segment, I couldn't find any option to filter out the notifications according to Android device models (it's available for iOS in UA).
    2. While sending image notifications, sometimes the image is not displayed on expanding the notifications. (I'll further investigate and attach any logs, if I can reproduce it again, as the frequency is low (2/10).) Also, UA requires an image url for displaying the picture in notifications which requires me to host it somewhere. Is there any option to upload the image?
    Thanks in advance.

    Comment actions Permalink
    0
  • Gaurav,

    You are correct, there are no options to filter out by Android device models. The reason being is because there can be potentially a very large variety of Android Device models that exist out there, so these were left out in the Device Property options.

     

    For expanding the notification, you'll want to see if there are other notifications in your notification center. Often times if there are other notifications that have a higher priority, it won't allow you to expand the other notifications in the notification center until the others were dismissed.

    There is no option to upload an image for displaying in the push itself, but I believe it is an option we're looking at in the future.

    Comment actions Permalink
    0

Please sign in to leave a comment.