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

37 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 @...

    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
  • Hello @..., I hope you're doing well!!

    I do implemented the Notification Service extension on my application and for my case, when I run the application from the Xcode the Push Notifications arrived with no problem, but when I do a build and install via Firebase distribution or TestFlight the Push Notification don't arrive...
    I already reimplemented the feature and change the configuration, but still not working... 

    In my Podfile

    target 'Dev' do
    pod 'AirshipExtensions/NotificationService'
    end
    target 'Live' do
    pod 'AirshipExtensions/NotificationService'
    end
     
    In the code 

    import AirshipExtensions

    class NotificationService: UANotificationServiceExtension {

    }

    Comment actions Permalink
    0
  • Hi Daniel!

    That sounds like that could potentially be a Dev. vs. Prod. issue.

    In order to set up pushes for a TestFlight build, your project needs to be set up with a Production Project in Airship, which includes a Production APNS Certificate or using the Token Auth. Regardless, a TestFlight build still needs to be pointing to a Production project in Airship so that it can connect to Production APNS servers when sending pushes.

    Is this the case for your project? You may also be able to check your Error Console when you're sending a push to see if there are any errors there that might clue us in to what's going on.

    Comment actions Permalink
    0
  • Hello @...

    I already have the Dev and Prod setup in the Airship console, it was working before we implemented the Notification Service Extension, after we implemented the PN are not working anymore

    Could we schedule a meeting to talk about it? Then I can share my screen with you...

    Comment actions Permalink
    0
  • Hi Daniel,

    I see you're currently talking with one of our Support Engineers in a separate support ticket. Looks like there are some important logging information in that ticket, which we can use to troubleshoot. I'll chat with that Engineer and we can set up a call if necessary.

    Comment actions Permalink
    0

Please sign in to leave a comment.