Push Notifications

Although it is up to the SDK integrator to configure their app for push notifications, to receive push notifications from the biid Identity Service, the device must first be registered with the service.

Register

To register a device to receive push notifications, the device token returned from the didRegisterForRemoteNotificationsWithDeviceToken callback method should be passed to the biid identity service as follows:

Swift3

    SDK.getClient.registerUserDevice(withDeviceToken: deviceToken,
        onSuccess: {
            // Handle successful registration
        }, onNoConnection: {
            // Handle no connection Error
        }, onInvalidToken: { (error) in
            // Handle invalid token error
        }, onClientError: { (error) in
            // Handle client error
    })  

ObjC

    [SDK.getClient registerUserDeviceWithDeviceToken:deviceToken
        onSuccess:^{
            // Handle successful registration
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

Unregister

It is also possible to opt out of receiving push notifications by unregistering the device as follows:

Swift3

    SDK.getClient.unregisterUserDevice (
        onSuccess: {
            // Handle successful "un-registration"
        }, onNoConnection: {
            // Handle no connection Error
        }, onInvalidToken: { (error) in
            // Handle invalid token error
        }, onClientError: { (error) in
            // Handle client error
    })  

ObjC

    [SDK.getClient unregisterUserDeviceOnSuccess:^{
            // Handle successful "un-registration"
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

Notification Handling

Although it is possible for the integrator app to parse incoming push notifications directly, it is highly recommended to use the SDK’s onPushNotificationReceived helper function to generate a BiidNotification object from the push notification’s userInfo payload.

Swift3

    SDK.getClient.onPushNotificationReceived(userInfo, onSuccess: { (biidNotification) in
        // Handle biid notification
    }) { (error) in
        // Handle client error
    }

ObjC

    [SDK.getClient onPushNotificationReceivedWithUserInfo:userinfo
        onSuccess:^(BiidNotification * _Nonnull biidNotification) {
            // Handle notification
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
     ];

Documentation