Projector
public class Projector: NSObject
The Projector SDK singleton object
-
Shared instance of the Projector object
Declaration
Swift
public static let shared = Projector()
-
The application token from the Projector dashboard - retrieved during registration
Declaration
Swift
public var appToken: String!
-
The device token - passed to the Projector object from the
UNUserNotificationCenterDelegate
implementationexample:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Projector.shared.deviceToken = deviceToken }
Declaration
Swift
public var deviceToken: Data!
-
The device’s push token registered with the Projector shared instance
Declaration
Swift
public var pushToken: String
-
The default authorization options set by the Projector class, includes
.alert
,.badge
and.sound
You are free to set these through this public field.
Declaration
Swift
public var authorizationOptions: UNAuthorizationOptions = Projector.defaultAuthorizationOptions
-
The optional
UNUserNotificationCenterDelegate
. This is set byinitUserNotifications(appToken:, delegate:)
method usually.You are free to set this through this public field.
Declaration
Swift
public var delegate: UNUserNotificationCenterDelegate?
-
Register for user notifications with optional
UNAuthorizationOptions
and a completion handlerThis is called by
initUserNotifications(appToken:, delegate:)
implicitly. However you may call this at a time that suits you, for example if you want to prompt the user to allow notifications at a later time.Declaration
Swift
public func registerForNotifications(options: UNAuthorizationOptions? = nil, completionHandler: (@escaping (Bool, Error?) -> Void)? = nil)
Parameters
options
authorization options, if not set default
[.alert, .badge, .sound]
is authorized.completionHandler
the completion handler passed through to the Projector object
Return Value
Void
-
Set the notification center
UNAuthorizationOptions
if provided, or set the default[.alert, .badge, .sound]
Projector options.Declaration
Swift
public func requestAuthorization(options: UNAuthorizationOptions = Projector.defaultAuthorizationOptions, completionHandler: @escaping (Bool, Error?) -> Void)
Parameters
options
authorization options, if not provided - uses default
[.alert, .badge, .sound]
parameters.completionHandler
the completion handler passed through to the Projector object
Return Value
Void
-
Set the notification categories supported in the application.
Note
This is called with an empty set byinitUserNotifications(appToken:, delegate:)
. This enables ProjectorKit to support projector features.Note
You must call this method with your categories at some point in the app delegate early application lifecycle.
Declaration
Swift
public func setNotificationCategories(_ categories: Set<UNNotificationCategory>)
Parameters
categories
the complete set of your application’s supported
UNNotificationCategory
objects.Return Value
Void
-
Add a notification request to the delegated
UNNotificationCenter
.Declaration
Swift
public func add(_ request: UNNotificationRequest, withCompletionHandler completionHandler: (@escaping (Error?) -> Void)? = nil)
Parameters
request
the request object to add to the delegated notification center.
completionHandler
the error handling completion handler passed down to the delegated notification center.
Return Value
Void
-
Remove the provided notifications (using their identification strings) from the delegated notification center
Declaration
Swift
public func removeDeliveredNotifications(withIdentifiers identifiers: [String])
Parameters
identifiers
the delivered notification identifiers to select for removal from the notification center delegate
Return Value
Void
-
Set the application-specific user identification string enabling identification in the Projector platform.
Declaration
Swift
public func setUserId(id: String)
Parameters
id
your application’s unique user identification string
Return Value
Void
-
Projector proxy method for the
UIApplicationDelegate
methoddidFinishLauchingWithOptions(application:, launchOptions:)
This must be called where your application implements this delegate method from
UIApplicationDelegate
Declaration
Swift
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
Parameters
application
the application object to proxy through
launchOptions
the launch options to proxy through
Return Value
Bool
-
Projector proxy method for the
UIApplicationDelegate
methodapplicationWillEnterForeground()
This must be called where your application implements this delegate method from
UIApplicationDelegate
Declaration
Swift
public func applicationWillEnterForeground()
Return Value
Void
-
Projector proxy method for the
UIApplicationDelegate
methodapplicationWillEnterBackground()
This must be called where your application implements this delegate method from
UIApplicationDelegate
Declaration
Swift
public func applicationDidEnterBackground()
Return Value
Void
-
Projector proxy method for the
UIApplicationDelegate
methodapplicationWillTerminate()
This must be called where your application implements this delegate method from
UIApplicationDelegate
Declaration
Swift
public func applicationWillTerminate()
Return Value
Void
-
Projector proxy method for the
UIApplicationDelegate
methodapplicationDidBecomeActive()
This must be called where your application implements this delegate method from
UIApplicationDelegate
Declaration
Swift
public func applicationDidBecomeActive()
Return Value
Void
-
Projector method called inside the
UIApplicationDelegate
methodapplication(application:, didReceiveRemoteNotification userInfo:, fetchCompletionHandler completionHandler:)
This must be called where your application implements this delegate method from
UIApplicationDelegate
Note
Projector requires the userInfo dictionary data, however we accept aUNNotificationRequest
object, so as not to interfere in cases that you wish to handle thefetchCompletionHandler
yourself. See the integration documentation for more details.See
UNNotificationRequest.withRemoteNotification(userInfo:)
Declaration
Swift
public func didReceiveRemoteNotification(request: UNNotificationRequest)
Parameters
request
the intercepted
UNNotificationRequest
objectReturn Value
Void
-
Initialize the application to use the Projector app token, register for notifications with the user, delegate the notification center and set the default Projector notification categories.
Declaration
Swift
public func initUserNotifications(appToken: String, delegate: UNUserNotificationCenterDelegate)
Parameters
appToken
The app token provided to you through the Projector dashboard
delegate
The application’s
UNUserNotificationCenterDelegate
objectReturn Value
Void