Skip to content

Push notifications allow developers to reach users, even when users aren't actively using an app! With the latest update of iOS Apple provide very useful extensions which are user-friendly. In this tutorial, I am going to share the configuration, set up of Notification with the media attachments like.

License

Notifications You must be signed in to change notification settings

Mindinventory/MI-CustomNotification

Repository files navigation

MI-Notification

Push notifications allow developers to reach users, even when users aren't actively using an app! With the latest update of iOS Apple provide very useful extensions which are user-friendly. In this tutorial, I am going to share the configuration, set up of Notification with the media attachments like. Read more from MEDIUM

  • Image
  • Audio
  • Video

IMG_9422 2 IMG_9422 IMG_9423 3

Installation

Install the below pod to your project.

pod 'Firebase/Core'
pod 'Firebase/Messaging

SetUp

Set up the firebase account and Developer account with require AppID, certificate, Provisioning profiles, and Googleserivce file.

Project SetUp

Drag and Drop the file UIApplication+CustomNotification or add the floder MIAppDelegateExtension from the project folder and add to your project.

Modify the AppDelagate

import Firebase

Call FirebaseApp.configure() and NotificationConfiguration(application) in didFinishLaunchingWithOptions Method

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
   FirebaseApp.configure()
   NotificationConfiguration(application)
   return true
}

Set Up NotificationServiceExtension

Add Notification Service extension as per the below screenshot and set up the Notification Service extension inside project

IMG_9416

Notification Service Project SetUp

Drag and Drop the file MIService or add the floder MINotificationServiceExtension from the Notification Service project folder and add to your project.

Modify the NotificationService

Inherit NotificationService from the MIService and wrtie down the following method only

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

NOTE

Please verify the UNNotificationCategory Identifier in UIApplication+CustomNotification file and inside MIService file it should be the same like you set in your notification payload.

Please take care of the bundle id of Notification Service project it should be compulsory prefix with the main project bundle ID. See the demo project's both bundle id main project and Notification Service project BundleId

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MI-Notificaion is MIT-licensed.

About

Push notifications allow developers to reach users, even when users aren't actively using an app! With the latest update of iOS Apple provide very useful extensions which are user-friendly. In this tutorial, I am going to share the configuration, set up of Notification with the media attachments like.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published