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
Install the below pod to your project.
pod 'Firebase/Core'
pod 'Firebase/Messaging
Set up the firebase account and Developer account with require AppID, certificate, Provisioning profiles, and Googleserivce file.
Drag and Drop the file UIApplication+CustomNotification or add the floder MIAppDelegateExtension from the project folder and add to your project.
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
}
Add Notification Service extension as per the below screenshot and set up the Notification Service extension inside project
Drag and Drop the file MIService or add the floder MINotificationServiceExtension from the Notification Service project folder and add to your project.
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)
}
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
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.
MI-Notificaion is MIT-licensed.