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
UNUserNotificationCenterDelegateimplementationexample:
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,.badgeand.soundYou 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
UNAuthorizationOptionsand 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
optionsauthorization options, if not set default
[.alert, .badge, .sound]is authorized.completionHandlerthe completion handler passed through to the Projector object
Return Value
Void
-
Set the notification center
UNAuthorizationOptionsif 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
optionsauthorization options, if not provided - uses default
[.alert, .badge, .sound]parameters.completionHandlerthe 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
categoriesthe complete set of your application’s supported
UNNotificationCategoryobjects.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
requestthe request object to add to the delegated notification center.
completionHandlerthe 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
identifiersthe 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
idyour application’s unique user identification string
Return Value
Void
-
Projector proxy method for the
UIApplicationDelegatemethoddidFinishLauchingWithOptions(application:, launchOptions:)This must be called where your application implements this delegate method from
UIApplicationDelegateDeclaration
Swift
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> BoolParameters
applicationthe application object to proxy through
launchOptionsthe launch options to proxy through
Return Value
Bool
-
Projector proxy method for the
UIApplicationDelegatemethodapplicationWillEnterForeground()This must be called where your application implements this delegate method from
UIApplicationDelegateDeclaration
Swift
public func applicationWillEnterForeground()Return Value
Void
-
Projector proxy method for the
UIApplicationDelegatemethodapplicationWillEnterBackground()This must be called where your application implements this delegate method from
UIApplicationDelegateDeclaration
Swift
public func applicationDidEnterBackground()Return Value
Void
-
Projector proxy method for the
UIApplicationDelegatemethodapplicationWillTerminate()This must be called where your application implements this delegate method from
UIApplicationDelegateDeclaration
Swift
public func applicationWillTerminate()Return Value
Void
-
Projector proxy method for the
UIApplicationDelegatemethodapplicationDidBecomeActive()This must be called where your application implements this delegate method from
UIApplicationDelegateDeclaration
Swift
public func applicationDidBecomeActive()Return Value
Void
-
Projector method called inside the
UIApplicationDelegatemethodapplication(application:, didReceiveRemoteNotification userInfo:, fetchCompletionHandler completionHandler:)This must be called where your application implements this delegate method from
UIApplicationDelegateNote
Projector requires the userInfo dictionary data, however we accept aUNNotificationRequestobject, so as not to interfere in cases that you wish to handle thefetchCompletionHandleryourself. See the integration documentation for more details.See
UNNotificationRequest.withRemoteNotification(userInfo:)Declaration
Swift
public func didReceiveRemoteNotification(request: UNNotificationRequest)Parameters
requestthe intercepted
UNNotificationRequestobjectReturn 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
appTokenThe app token provided to you through the Projector dashboard
delegateThe application’s
UNUserNotificationCenterDelegateobjectReturn Value
Void
View on GitHub
Projector Class Reference