PushNotifications
@objc
public final class PushNotifications : NSObject
The top-level entrypoint to the Beams Swift SDK.
-
The object that acts as the delegate of push notifications.
Declaration
Swift
public weak var delegate: InterestsChangedDelegate? -
Creates a
PushNotificationsobject with a giveninstanceId.Declaration
Swift
@objc public init(instanceId: String)Parameters
instanceIdThe instance identifier (from your app dashboard).
-
Returns a shared singleton PushNotifications object that can be accessed from anywhere in your project.
Declaration
Swift
@objc public static let shared: PushNotificationsStatic.Type -
Start PushNotifications service.
Declaration
Swift
@objc public func start() -
Register to receive remote notifications via Apple Push Notification service.
Convenience method is using
.alert,.sound, and.badgeas default authorization options.Declaration
Swift
@objc public func registerForRemoteNotifications() -
Register to receive remote notifications via Apple Push Notification service.
-
Register to receive remote notifications via Apple Push Notification service.
Declaration
Swift
@objc public func registerForRemoteNotifications(options: NSApplication.RemoteNotificationType)Parameters
optionsA bit mask specifying the types of notifications the app accepts. See NSApplication.RemoteNotificationType for valid bit-mask values.
-
Set user id.
Declaration
Swift
@objc public func setUserId(_ userId: String, tokenProvider: TokenProvider, completion: @escaping (Error?) -> Void)Parameters
userIdUser id.
tokenProviderToken provider that will be used to generate the token for the user that you want to authenticate.
completionThe block to execute after attempt to set user id has been made.
-
Disable Beams service.
This will remove everything associated with the Beams from the device and Beams server.
Declaration
Swift
@objc public func stop(completion: @escaping () -> Void)Parameters
completionThe block to execute after the device has been deleted from the server.
-
Clears all the state on the SDK leaving it in the empty started state.
This will remove the current user and all the interests associated with it from the device and Beams server. Device is now in a fresh state, ready for new subscriptions or user being set.
Declaration
Swift
@objc public func clearAllState(completion: @escaping () -> Void)Parameters
completionThe block to execute after the device has been deleted from the server.
-
Register device token with PushNotifications service.
Precondition
deviceTokenshould not be nil.Declaration
Swift
@objc public func registerDeviceToken(_ deviceToken: Data)Parameters
deviceTokenA token that identifies the device to APNs.
-
Subscribes the device to an interest.
Precondition
interestshould not be nil.Throws
An error of type
InvalidInterestErrorDeclaration
Swift
@objc public func addDeviceInterest(interest: String) throwsParameters
interestInterest that you want to subscribe your device to.
-
Sets the subscriptions state for the device. Any interests not in the set will be unsubscribed from, so this will replace the interest set by the one provided.
Precondition
interestsshould not be nil.Throws
An error of type
MultipleInvalidInterestsErrorDeclaration
Swift
@objc public func setDeviceInterests(interests: [String]) throwsParameters
interestsInterests that you want to subscribe your device to.
-
Unsubscribe the device from an interest.
Precondition
interestshould not be nil.Throws
An error of type
InvalidInterestErrorDeclaration
Swift
@objc public func removeDeviceInterest(interest: String) throwsParameters
interestInterest that you want to unsubscribe your device from.
-
Unsubscribes the device from all the interests.
- Tag: clearDeviceInterests
Declaration
Swift
@objc public func clearDeviceInterests() throws -
Get the interest subscriptions that the device is currently subscribed to.
Declaration
Swift
@objc public func getDeviceInterests() -> [String]?Return Value
Array of interests
-
Handle Remote Notification.
Declaration
Swift
@discardableResult @objc public func handleNotification(userInfo: [AnyHashable : Any]) -> RemoteNotificationTypeParameters
userInfoRemote Notification payload.
View on GitHub
PushNotifications Class Reference