Version: 5.5.0
This document describes integration of the Blesh iOS SDK with your iOS application.
Blesh iOS SDK collects location information from a device on which the iOS application is installed. Blesh Ads Platform uses this data for creating and enhancing audiences, serving targeted ads, and insights generation.
5.5.0 (Released 2023-10-06)
5.4.10 (Released 2023-07-20)
5.4.9 (Released 2023-07-14)
5.4.8 (Released 2023-04-15)
5.4.7 (Released 2023-01-12)
5.4.6 (Released 2022-12-20)
5.4.5 (Released 2022-11-11)
5.4.4 (Released 2022-11-10)
5.4.3 (Released 2022-11-08)
5.4.2 (Released 2022-08-26)
5.4.1 (Released 2022-08-15)
5.4.0 (Released 2022-07-03)
5.3.0 (Released 2022-04-12)
5.2.10 (Released 2022-03-22)
5.2.9 (Released 2021-11-22)
5.2.8 (Released 2021-09-22)
5.2.7 (Released 2021-05-04)
5.2.6 (Released 2020-10-05)
5.2.5 (Released 2020-07-27)
5.2.4 (Released 2020-07-27)
5.2.3 (Released 2020-05-20)
5.2.2 (Released 2020-05-18)
5.2.1 (Released 2020-05-08)
5.2.0 (Released 2020-05-02)
5.1.5 (Released 2020-04-18)
5.1.4 (Released 2020-01-20)
5.1.3 (Released 2020-01-07)
5.1.2 (Released 2020-01-07)
5.1.1 (Released 2020-01-06)
5.1.0 (Released 2019-12-27)
5.0.1 (Released 2019-11-28)
5.0.0 (Released 2019-11-26)
In order to integrate the Blesh iOS SDK make sure you are:
Always Embed Swift Standard Libraries
" build option (or the "Embedded Content Contains Swift Code
" build option for older versions of Xcode) if your application is developed using the Objective-C language
Note: Make sure that you declare that "your app uses IDFA" on App Store Connect. Otherwise, your app may be rejected on review. Blesh iOS SDK collects IDFA from the device, in full compliance with the Apple requirements.
The Blesh iOS SDK can be added by using various dependency managers or manually.
Newer Xcode versions support adding packages through the IDE interface. Blesh iOS SDK can be easily integrated by following steps below.
Steps to add:
Add Packages
" in the "File
" menu.Search or Enter Package URL
".Up to Next Major Version
" for the "Dependency Rule
" input. This will allow you to easily keep Blesh iOS SDK up-to-date.Add to Project
" input.Add Package
" button and select your application project in the "Add to Target
" column.Add Package
" button.Referencing the BleshSDK
pod in the Podfile
will be sufficient to add the Blesh iOS SDK to your project.
Steps to add:
Podfile
then you can create one by running the following command on the terminal:pod init
BleshSDK
in the Podfile
:target 'YOUR_APPLICATION_NAME' do
# ... beginning of your Podfile ...
pod 'BleshSDK' # this will reference the Blesh iOS SDK 5
# ... remaining of your Podfile ...
end
Note: Replace
YOUR_APPLICATION_NAME
with the name of your application in thetarget
section
pod install
You can download the SDK from the following repository:
https://github.com/bleshcom/Blesh-iOS-SDK.git
To integrate a specific version of the SDK, a git revision with the tag for the desired version should be checked out.
BleshSDK.framework
to your Xcode projectBlesh iOS SDK must be notified when a push notification is about to be displayed and when a user interacted with a push notification. This will allow Blesh iOS SDK to:
Blesh iOS SDK supports remote push notifications throught Apple Push Notification service (APNs) and Firebase Cloud Messaging (FCM).
Note: APNs & Firebase certificates need to be registered on the Blesh Publisher Portal.
Below examples assume that you have integrated Apple Push Notification service with your application. Please refer to the APNs iOS Documentation for more information.
Swift:
import UIKit
import UserNotifications
import BleshSDK
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// mark this class as a UNUserNotificationCenterDelegate
UNUserNotificationCenter.current().delegate = self
// enable remote notifications
application.registerForRemoteNotifications()
// ... rest of the method ...
return true
}
// support remote notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// notify Blesh SDK
BleshSdk.sharedInstance.didReceiveRemoteNotification(userInfo) { UIBackgroundFetchResult in
completionHandler(.newData)
}
// ... rest of the method ...
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
NSLog("Failed to register for remote notifications: \(error)")
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// notify Blesh SDK
BleshSdk.sharedInstance.didReceiveDeviceToken(deviceToken)
// ... rest of the method ...
}
// this method will be called when app received push notifications in foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
// deliver to Blesh SDK
BleshSdk.sharedInstance.didReceiveUNNotificationResponse(response)
completionHandler()
}
// ... rest of the class ...
}
Example: Objective-C (AppDelegate.h)
#import <UserNotifications/UserNotifications.h>
// ... rest of imports ...
@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
// ... rest of the interface ...
@end
Example: Objective-C (AppDelegate.m)
#import <BleshSDK/BleshSDK.h>
// ... rest of imports ...
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// mark this class as a UNUserNotificationCenterDelegate
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
// enable remote notifications
[[UIApplication sharedApplication] registerForRemoteNotifications];
// ... rest of the method ...
return YES;
}
// support remote notifications
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// notify Blesh SDK
[[BleshSdk sharedInstance] didReceiveRemoteNotification:userInfo completion:^(UIBackgroundFetchResult result) {
completionHandler(UIBackgroundFetchResultNewData);
}];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// notify Blesh SDK
[[BleshSdk sharedInstance] didReceiveDeviceToken:deviceToken];
}
// this method will be called when app received push notifications in foreground
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionBadge);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
// deliver to Blesh SDK
[[BleshSdk sharedInstance] didReceiveUNNotificationResponse:response];
completionHandler();
}
// ... rest of the class ...
@end
Below examples assume that you have integrated Firebase Messaging with your application. Please refer to the FCM iOS Documentation for more information.
Swift:
import UIKit
import UserNotifications
import BleshSDK
import FirebaseMessaging
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// mark this class as a UNUserNotificationCenterDelegate
UNUserNotificationCenter.current().delegate = self
// enable remote notifications
application.registerForRemoteNotifications()
// ... rest of the method ...
return true
}
// support remote notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// notify FCM
Messaging.messaging().appDidReceiveMessage(userInfo)
// notify Blesh SDK
BleshSdk.sharedInstance.didReceiveRemoteNotification(userInfo) { UIBackgroundFetchResult in
completionHandler(.newData)
}
// ... rest of the method ...
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// notify FCM
Messaging.messaging().apnsToken = deviceToken
// notify Blesh SDK
BleshSdk.sharedInstance.didReceiveDeviceToken(deviceToken)
// ... rest of the method ...
}
// this method will be called when app received push notifications in foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// deliver to FCM
Messaging.messaging().appDidReceiveMessage(notification.request.content.userInfo)
completionHandler([.alert, .badge, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
// deliver to FCM
Messaging.messaging().appDidReceiveMessage(response.notification.request.content.userInfo)
// deliver to Blesh SDK
BleshSdk.sharedInstance.didReceiveUNNotificationResponse(response)
completionHandler()
}
// ... rest of the class ...
}
Example: Objective-C (AppDelegate.h)
#import <UserNotifications/UserNotifications.h>
#import <FirebaseMessaging/FirebaseMessaging.h>
// ... rest of imports ...
@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate>
// ... rest of the interface ...
@end
Example: Objective-C (AppDelegate.m)
#import <BleshSDK/BleshSDK.h>
// ... rest of imports ...
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// mark this class as a UNUserNotificationCenterDelegate
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
// enable remote notifications
[[UIApplication sharedApplication] registerForRemoteNotifications];
// ... rest of the method ...
return YES;
}
// support remote notifications
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// notify FCM
[[FIRMessaging messaging] appDidReceiveMessage:userInfo];
// notify Blesh SDK
[[BleshSdk sharedInstance] didReceiveRemoteNotification:userInfo completion:^(UIBackgroundFetchResult result) {
completionHandler(UIBackgroundFetchResultNewData);
}];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// notify FCM
[[FIRMessaging messaging] setAPNSToken:deviceToken];
// notify Blesh SDK
[[BleshSdk sharedInstance] didReceiveDeviceToken:deviceToken];
}
// this method will be called when app received push notifications in foreground
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
// deliver to FCM
[[FIRMessaging messaging] appDidReceiveMessage:notification.request.content.userInfo];
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionBadge);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
// deliver to FCM
[[FIRMessaging messaging] appDidReceiveMessage:response.notification.request.content.userInfo];
// deliver to Blesh SDK
[[BleshSdk sharedInstance] didReceiveUNNotificationResponse:response];
completionHandler();
}
// ... rest of the class ...
@end
Blesh iOS SDK utilizes following frameworks. Please make sure that your project references all of them:
Blesh iOS SDK plays its default sound file BleshNotification.caf
for supported ads. You can download the sound file from this link and copy into your application's Supporting Files
folder. If this file doesn't exist then the SDK plays the default iOS notification sound.
In order to provide proper notifications and proper beacon tracking, you need to get some permission from the application user, after your application is installed. Per iOS User guides, applications can ask for required permissions with their own sentences. The permissions can be configured in Info.plist
file.
Blesh iOS SDK uses iBeacon protocol which requires location permission by default. Blesh iOS SDK needs to detect beacons and geofences even when the app is at background or killed. Therefore you have to ask for "Always usage of location" to your users.
Until iOS 11, when the users give permission for location usage, it was considered as "Always" and applications could use the location when they are killed or at background.
After iOS 11, the rules have changed and users were able to give location usage permission only when the application is in use. As a result, for iOS v11 and later, applications have to ask for two different types of location permissions: WhenInUse
or AlwaysAndWhenInUse
.
For backward compatibility, your application should include all three descriptors given below for location permission:
In the description field of location permission entries, we recommend you to encourage your users to allow "Always use my location", in order to have a better performance of the system. In the below subsections, we provide some sample description text. Please check and consider them.
Please note that, with iOS version 11, applications must include all of the below 3 descriptors in their Info.plist
file for backward compatibility with older OS versions.
This descriptor is used for iOS 11 and later. Provides permission for both when in use and when killed.
Sample Text: "This application uses your location in order to inform you about interesting offers nearby. We advice you to choose Always option to get the offers even when you are not using the application!"
You can insert it into your Info.plist
file in the following syntax.
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string><# insert always and when in use usage description text #></string>
This descriptor is used for iOS 10 and before versions. Provides permission for both when in use and when killed.
Sample Text: "This application uses your location in order to inform you about interesting offers nearby. We advice you to choose Always option to get the offers even when you are not using the application!"
You can insert it into your Info.plist
file in the following syntax.
<key>NSLocationAlwaysUsageDescription</key>
<string><# insert always usage description text #></string>
This descriptor is used in all iOS versions. Provides permission for only when the application is in use. We advice you to warn your users about very low performance on receiving nearby offers.
Sample Text: “This application uses your location in order to inform you about interesting offers nearby. Allowing location when in use only may result in poor performance in finding nearby offers!”
You can insert it into your Info.plist
file in the following syntax.
<key>NSLocationWhenInUseUsageDescription</key>
<string><# insert when in use usage description text #></string>
In order to utilize capabilities of the Blesh iOS SDK, it needs to be started at some point of your application's lifecycle.
Blesh iOS SDK requires the Blesh Ads Platform Access Key. You may need to create one for the iOS platform at the Blesh Publisher Portal. If you do not have an account at the Blesh Publisher Portal please contact us at [email protected]. You can set your key in your application's Info.plist
file with the Blesh Platform Access Key
key:
<key>Blesh Platform Access Key</key>
<string>YOUR_SECRET_KEY_HERE</string>
Alternatively, you can provide the Blesh Ads Platform Access Key via the SDK start
method as documented in the next section.
You can either create & manage a new instance of BleshSdk
or you can access the BleshSdk
singleton instance through BleshSdk.sharedInstance
.
In order to continue to receive notifications even when the app is killed/not running in the background, invoking start
method should not require the application to be in the foreground. Please note that best practice is starting Blesh under applicationDidFinishLaunchingWithOptions in the app delegate.
BleshSdk
contains following start
methods:
Swift:
start(
withSecretKey: String?,
withApplicationUser: BleshSdkApplicationUser?,
withConfiguration: BleshSdkConfiguration?,
completionHandler: ((BleshSdkStartState) -> Void)?)
Objective-C:
- (void)startWithApplicationUser:(BleshSdkApplicationUser *)applicationUser
withConfiguration:(BleshSdkConfiguration *)configuration
completionHandler:(void (^)(enum BleshSdkStartState))completionHandler;
- (void)startWithSecretKey:(NSString *)secretKey
withApplicationUser:(BleshSdkApplicationUser *)applicationUser
withConfiguration:(BleshSdkConfiguration *)configuration
completionHandler:(void (^)(enum BleshSdkStartState))completionHandler;
If you do not choose to utilize the Info.plist
file to define the Blesh Ads Platform Access Key, you may optionally pass it using the withSecretKey
parameter.
withApplicationUser
parameter allows you to enchance the audience data by providing information about the primary user (subscriber) of your application. You can give any information which makes the subscriber unique in your application's understanding. The BleshSdkApplicationUser
class contains the following:
Description | Swift Property | Objective-C Property | Example |
---|---|---|---|
Optional unique identifier of the user | userId: String? | (NSString *)userId | 42 |
Optional gender of the user (.female or .male) | gender: BleshSdkApplicationUserGender? | (NSNumber *)genderCode | .female (Swift) 0 (Obj-c) |
Optional year of birth of the user | yearOfBirth: Int? | (NSNumber *)yearOfBirth | 1999 |
Optional email address of the user | email: String? | (NSString *)email | [email protected] |
Optional mobile phone number of the user | phoneNumber: String? | (NSString *)phoneNumber | +905550000000 |
Optional extra information for the user | other: Dictionary<String,String>? | (NSDictionary<NSString *, NSString *> *)other |
Note:
phoneNumber
details are never sent in plain-text to the Blesh Ads Platform. These values are always irreversibly hashed so that no personally identifiable information is stored.
withConfiguration
parameter allows you to configure the behaviour of the Blesh iOS SDK. The BleshSdkConfiguration
class contains the following:Property | Type | Description | Example |
---|---|---|---|
testMode | Bool | Use the SDK in the test mode (true) or use the SDK in the production mode (false) | false |
pushNotificationToken | String | Remote push notification token (device registration token) | Messaging.messaging().fcmToken |
For valid values of pushNotificationToken
please refer to the FCM iOS Documentation for more information.
Note:
testMode
is off by default. You can enable this mode during your integration tests. Production environment will not be effected when this flag is set totrue
.
completionHandler
parameter allows you to execute your business logic after the Blesh iOS SDK initialization is succeeded or failed.You can start the Blesh iOS SDK by simply invoking the start
method of the shared instance:
Swift:
BleshSdk.sharedInstance.start()
Objective-C:
[[BleshSdk sharedInstance] start];
You can start the Blesh iOS SDK by simply invoking the start
method of the instance:
Swift:
let bleshSdk = BleshSdk()
bleshSdk.start()
Objective-C:
BleshSdk* bleshSdk = [[BleshSdk alloc] init];
[bleshSdk start];
Swift:
let bleshSdkConfiguration = BleshSdkConfiguration(
testMode: false,
pushNotificationToken: Messaging.messaging().fcmToken ?? BleshSdk.sharedInstance.pushNotificationToken
)
let bleshSdkApplicationUser = BleshSdkApplicationUser(
userId: "42",
gender: .female,
yearOfBirth: 1999,
email: "[email protected]",
phoneNumber: "+905550000000",
other: nil
)
BleshSdk.sharedInstance.start(
withApplicationUser: bleshSdkApplicationUser,
withConfiguration: bleshSdkConfiguration) {
(sdkState) -> () in
// ... INSERT BUSINESS LOGIC HERE ...
NSLog("BleshSDK start completed: " + sdkState.description)
}
Objective-C:
BleshSdkConfiguration *configuration = [[BleshSdkConfiguration alloc]
initWithTestMode:false
adsEnabled:true
pushNotificationToken:[FIRMessaging messaging].FCMToken ?: [BleshSdk sharedInstance].pushNotificationToken];
BleshSdkApplicationUser *user = [[BleshSdkApplicationUser alloc] initWithUserId:@"42"
genderCode:0 // 0: female 1: male
yearOfBirth:@1999
email:@"[email protected]"
phoneNumber:@"+905550000000"
other:nil];
[[BleshSdk sharedInstance] startWithApplicationUser:user
withConfiguration:configuration
completionHandler:^(enum BleshSdkStartState state) {
// ... INSERT BUSINESS LOGIC HERE ...
if (state == BleshSdkStartStateFailure) {
NSLog(@"BleshSDK start completed: failure");
} else if (state == BleshSdkStartStateSkipped) {
NSLog(@"BleshSDK start completed: skipped");
} else {
NSLog(@"BleshSDK start completed: success");
}
}];
Starting from Blesh iOS SDK 4.0.7, the SDK does not ask the user for permissions. Your application needs to ask location permissions. See "Reviewing Permissions" section for more information.
When the location permission changes, your application should call the didChangeLocationAuthorization
method of BleshSdk
with the new status.
Example: Swift
import UIKit
import BleshSDK
import CoreLocation
class MyViewController: UIViewController, CLLocationManagerDelegate {
var locationManager: CLLocationManager
required init?(coder aDecoder: NSCoder) {
self.locationManager = CLLocationManager()
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.distanceFilter = 10
self.locationManager.requestAlwaysAuthorization()
self.locationManager.requestLocation()
// ... rest of the method ...
}
public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
// Notify the Blesh iOS SDK about the change here
BleshSdk.sharedInstance.didChangeLocationAuthorization(status)
}
// ... rest of the controller ...
}
Example: Objective-C (ViewController.h)
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <BleshSDK/BleshSDK.h>
// ... rest of imports ...
@interface ViewController : UIViewController<CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
}
// ... rest of the interface ...
@end
Example: Objective-C (ViewController.m)
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
locationManager.distanceFilter = 10;
[locationManager requestAlwaysAuthorization];
[locationManager requestLocation];
// ... rest of the method ...
}
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
// Notify the Blesh iOS SDK about the change here
[[BleshSdk sharedInstance] didChangeLocationAuthorization:status];
// ... rest of the method ...
}
// ... rest of the class ...
@end
Blesh iOS SDK allows you to decide whether or not to display an ad. Following optional methods are provided by the BleshSdkDelegate
protocol:
optional func bleshSdk(_ sdk: BleshSdk, didCompleteStartWith state: BleshSdkStartState)
optional func bleshSdk(_ sdk: BleshSdk, willDisplayNotification notificationId: String) -> Bool
Example: Swift
import UIKit
import BleshSDK
class MyViewController: UIViewController, BleshSdkDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Mark this controller as the delegate of Blesh SDK
BleshSdk.sharedInstance.delegate = self
// ... rest of the method ...
}
func bleshSdk(_ sdk: BleshSdk, willDisplayNotification notificationId: String) -> Bool {
NSLog("BleshSDK will display the notification with id: \(notificationId)")
return true // allow BleshSDK to display this notification
}
// ... rest of the controller ...
}
To enable the presentation of images through remote push notifications, Apple mandates the inclusion of media in the notification by utilizing a Notification Service Extension.
Blesh iOS SDK supports downloading media attachments via the decorateRemoteNotification
function.
An example Notification Service Extension can be like the following:
Example: Swift
import UserNotifications
import BleshSDK
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
// Download and attach images
BleshSdk.sharedInstance.decorateRemoteNotification(request, bestAttemptContent: bestAttemptContent)
contentHandler(bestAttemptContent)
}
}
override func serviceExtensionTimeWillExpire() {
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
link |
Stars: 0 |
Last commit: 15 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics