Integrate APNS Push in your Swift application
AppDelegate should implement UNUserNotificationCenterDelegate
from UserNotifications
and then add registerForPush
method to AppDelegate and call that method inside application(_:didFinishLaunchingWithOptions:)
.
Explicit Authorization
Provisional Authorization
In Xcode go to File > New > Target.
Select Notification Service Extension from the template list.
Then in Next popup give it any product name, select your team, select swift language and click finish.
After clicking on “Finish”, a folder will be created with your given product name.
Swift Package Manager (SPM)
In Xcode, go to File > AddPackages to add a new dependency.
In that search bar, add suprsend-swift-sdk project github url https://github.com/suprsend/suprsend-swift-sdk
and keep the default version settings and click Add Package
button.
In second dialog box, select your Notification Service target from dropdown and click Add Package
button.
Cocoapods
Add the SuprSendSwift SDK to your Podfile as dependency to Notification Service Extension like below and then run pod install
.
Paste the below code in NotificationService.swift file. Replace YOUR_PUBLIC_KEY
with your public key.
By default SDK will handle only http deeplinks. If you want to handle custom deeplinks, implement SuprSendDeepLinkDelegate
in AppDelegate class and add the below code.
Example of AppDelegate.swift
file with all the above code.