Rich Push Notification image Not Showing For IOS 10.

Hello,

I have implemented Urban airship SDK for handling push notification. Using This Urban airship Implementation Guide.

"http://docs.urbanairship.com/platform/ios.html" 

 

But am Unable to show Images on notification.

 

Here is the payload which am getting from Server.

 

{
"_" = "channel_id";
aps = {
alert = {
body = testing;
title = "Boys and Girls club of Boston";
};
"mutable-content" = 1;
};
"com.urbanairship.media_attachment" = {
options = {
crop = {
height = "0.2";
width = "0.2";
x = "0.1";
y = "0.1";
};
time = 10;
};
url = (
"http://ladgbucket.s3.amazonaws.com/dev/users/1484421361file.jpeg"
);
};
"post_id" = 1;
"post_type" = news;
url = "http://ladgbucket.s3.amazonaws.com/dev/users/1484421361file.jpeg";
}

 

Didn't find what you were looking for?

New post

Comments

33 comments

  • Mohamed,

    The iOS App Extensions is specifically used for supporting images within push notifications for iOS. This is not a requirement for Android, however, as images are supported out the box.

    If, however, you are sending pushes from Firebase to your iOS devices, this may not work as Firebase might send a different payload than what the Airship SDK expects. Sending these pushes from the Airship platform to your iOS and Android devices would be the way to go.

    Comment actions Permalink
    0
  • Hi Michael Halka

    We are trying to integrate Rich Push Notification in ionic capacitor project. As per instructions, we created/added notification service extension. But it is not calling notification service and not displaying images in push notification. 

    Below is the source code written to download image from the url (shared via payload)

     

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {

            self.contentHandler = contentHandler

            bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

           

        

            if let bestAttemptContent = bestAttemptContent {

                if let attachmentString = bestAttemptContent.userInfo["media_attachment"] as? String,

                    let attachmentUrl = URL(string: attachmentString) {

                    let session = URLSession(configuration: URLSessionConfiguration.default)

                    let downloadTask = session.downloadTask(with: attachmentUrl, completionHandler: { (url, _, error) in

                        if let error = error {

                            print("Error downloading attachment: \(error.localizedDescription)")

                        } else if let url = url {

                            let attachment = try! UNNotificationAttachment(identifier: attachmentString,

                                                                           url: url,

                                                                           options: [UNNotificationAttachmentOptionsTypeHintKey: kUTTypePNG])

                            bestAttemptContent.attachments = [attachment]

                        }

                        contentHandler(bestAttemptContent)

                    })

                    downloadTask.resume()

                    }

            }

        }

     

    Payload:

    {

        "alert": {

          "title": "Test",

          "subtitle": "Test test",

          "body": "This episode we talk about Clean Architecture with Antonio Leiva."

        },

        "mutable-content": 1

      },

      "media_attachment": "https://koenig-media.raywenderlich.com/uploads/2016/11/Logo-250x250.png"

    }

     

    POD File:

     

    target "NotificationService" do

      pod 'AirshipExtensions/NotificationService'

    end

    Comment actions Permalink
    0
  • Hello!

    That's not quite how that will work. The Notification Service Extension is built so that you don't explicitly need to download the icon URL and display it yourself.

    You might take a look at our native iOS example which shows how the Service Extension is configured.

    https://github.com/urbanairship/ios-library/tree/main/SwiftSample

    This process will be essentially the same for Cordova/Ionic with making sure the Service Extension has correctly been added to your project as well as making sure the content of the Service Extension class is modified appropriately (according to Airship docs).

    There is no need to have any additional code to pull the icon from the payload to display it.

    If you're having trouble getting images to show up in your pushes, make sure that the image you're wanting to use is publicly available, is not larger than 5 MBs, and is hosted on a site that has the appropriate content type.

    Comment actions Permalink
    0

Please sign in to leave a comment.