Go to Signing & Capabilities and click + Capability and add Push Notifications
To support iOS Rich Notifications, you need to add Notification Service Extension
In Xcode, select Notification Service Extension from File > New > Target
Enter the Product Name. In this guide, we will define it as FlareLaneNotificationServiceExtension.
Set Minimum Deployments of the Notification Service Extension Target you just created to be the same as the main app target you are currently using.
4. Install SDK using CocoaPods
Add the following code to your Podfile
// Enable the Dynamic Framework
use_frameworks!
target 'YOUR_PROJECT_NAME' do
// Add the code below
pod 'FlareLane', '1.7.1'
end
// Add the name of the extension created previously.
// In this guide, FlareLaneNotificationServiceExtension.
target 'FlareLaneNotificationServiceExtension' do
pod 'FlareLane', '1.7.1'
end
Run pod install in the terminal
5. Initialization
(5-1. SwiftUI Only)
Since AppDelegate.swift is not created in the SwiftUI project, the file needs to be created first.
Create a new AppDelegate.swift file and add some code to <YOUR_PROJECT_NAME>App.swift file.
struct <YOUR_PROJECT_NAME>App:App {// Add the code below@UIApplicationDelegateAdaptor(AppDelegate.self)var appDelegate}
5-2. AppDelegate
importFlareLaneclassAppDelegate:UIResponder, UIApplicationDelegate {funcapplication(_application: UIApplication, didFinishLaunchingWithOptionslaunchOptions: [UIApplication.LaunchOptionsKey:Any]?) ->Bool { // Add the code below// To subscribe later, set the 3rd parameter to false and then run .subscribe() later. FlareLane.initWithLaunchOptions(launchOptions, projectId:"<INPUT_YOUR_PROJECT_ID>", requestPermissionOnLaunch:true)returntrue }}
@import FlareLane
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add the code below
// To subscribe later, set the 3rd parameter to false and then run the .subscribe() later.
[FlareLane initWithLaunchOptions:launchOptions projectId:@"INPUT_YOUR_PROJECT_ID", requestPermissionOnLaunch:true];
}
5-3. Notification Service Extension
Run Xcode again and edit the extension's file. Delete the pre-filled codes and only inherit FlareLaneNotificationServiceExtension.
After completing all the steps, build and run your app. Devices that subscribe to push notifications will be automatically added to FlareLane console's All Devices.
Before actual deployment, be sure to verify that the push notifications are being received properly on the device and that the statistics are accurately recorded when the push notifications are clicked.
7. Identify your user
FlareLane's device is 'anonymous' and you can match the device with your user based on the unique user ID that identifies your user.
Setting up User ID has many benefits. You can distinguish whether a user has signed-up, and push notifications can be sent based on the User ID.
Usually, when a user sign-up or log-in, you should execute setUserId.