How to get image in iOS push notification

How to get image in iOS push notification
January 10, 2020 3 Comments Development,iOS Development Pushpendra Kumar

Hello Developers, Here I am giving you quick review regarding how to get image in iOS push notification. This procedure called rich notification in iOS. So let’s come the point directly without waisting time.

At the very first you have to create all the certificate on the apple developer account. In Addition, You have to create one certificate for iOS Push notification. And After that you have to create keys. Once you completed with this process then follow the below steps.

How to get image in iOS push notification with procedure

  • Click on the Project Folder 
  • Click on Signing & Capability
  • Add New Capability from + Capability button
  • Now Type Push Notification
  • Add Background Modes in same way and Check Remote Notification
how to enable push notification in Xcode
how to enable push notification in Xcode

After that, Doing all this work move to next task.

Create new target in Xcode for notification

  • Add new Target in your project, Notification Content Extension
  • Add one more new target in your project Notification Service Extension
  • Change all the target to version 10.0
  • Also Change the Architecture with arm64 in both target. In addition Click on Main Project Target and select Build Setting Tab and Go to the Architectures. Here you need to write arm64 for every target.
Create new target in iOS
Create new target in iOS
Create notification service in ios
Create notification service in ios

After that, Add UNNotificationExtensionCategory  in Notification Content Extension Info.plist, As mentioned into the below image.

Add UNNotificationExtensionCategory  in Notification Content Extension

add notification category in info.plist
Add notification category in info.plist

After that, Now let’s move to the coding part. Go to NotificationService Swift file and update following code.

Great, Finally Change your NotificationViewController Which is inside Your Content Extension

Wonderful, You almost completed the coding part. For your kind information I want to tell you that in above code NotificationViewController.swift, I have use custom image_view. I Have given the reference to this from my MainInterface.storyboard

Please look into the below image.

How to get image in iOS push notification
How to get image in iOS push notification

In Addition, I want to tell you that. I have set this image 0 from to, 0,0 From let and right. And here I have give constant heigh 200. For your kind information I did not set any anchor from the bottom.

FCM generates an Instance ID, which is used as a registration token within FCM. When an Instance ID is generated the library will upload the identifier and configuration data to Firebase.If you want to get an explicit opt-in before using Instance ID, you can prevent generation at configure time by disabling FCM (and on Android, Analytics). To do this, add a metadata value to your Info.plist (not your GoogleService-Info.plist)

Now Finally, Have look on your payload. I have send this notification from Post Man. If you want to do the same then follow the given procedure on this link – LINK.

Great, In Conclusion I hope you are very clear about the push notification. If you have any question please comment below any time. Thanks for being here. Have a great time to you 😎😎😎

In Addition, If you are looking something interesting. Please follow the below links.

Tags
About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd (www.thecolourmoon.com). This website I have made so that I can meet with new challenges and can share here.
Leave Comment
  1. 1

    White Label SEO

    Awesome post! Keep up the great work! 🙂

    Reply
  2. 1

    AffiliateLabz

    Great content! Super high-quality! Keep it up! 🙂

    Reply
  3. 1

    Clear Phone Cases

    Wonderful article and I really appreciate your hard work.

    King regards,
    Demir Griffin

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *