Skip to content

Advanced

This section will provide more advanced features available in the BearSDK. Sample code is also available in our sample application.

Show Marker Without Scanning

The BearSDK also provides a method to display a marker without scanning it: showARSceneWithoutTracking(withMarkerId id: Int). Obviously you need the marker id to call this method.

The behavior is the same as when a marker is recognized from scan, but without tracking assets on the marker:

  • The marker and its assets will be displayed in the augmented reality view;
  • The scanner status will be changed to processing and after that to rendering or didFail(withError:) will be called if an error occurs.

Release resources

You may need to release the memory used by BearSDK, so you have to use releaseResources method. Resources will be acquired again when the new ARViewController or its subclass is initialized.

  • isLoaded - The status of the BearSDK resources;
  • releaseResources - Releases all BearSDK support resources. Ex.: default textures, initialized trackers and etc.

Note: once loaded Bear SDK resources will be kept until releaseResources is called. You should only release resources when user finishes enjoying augmented reality and switches to other app features.

Pause/Resume camera

In most cases BearSDK will control pause/resume camera automatically. But if you are need very specific behavior, you can disable automatic camera control and do it manually.

  • In ARViewController you have to change automaticCameraControl property to false;
  • Manage manually pause/resume camera using ARViewController handler object functions resumeCamera(animated: Bool) and pauseCamera(animated: Bool).

Push Notifications

ARGO Manager provides feature to manage application notification. This section explains how to enable this feature in BearSDK by linking it to Firebase.

The Firebase integration is handled application side and not inside BearSDK. Don't hesitate to check Firebase instruction for adding Firebase to your application and setup your Firebase cloud messaging client.

For the notifications to work with BearSDK, you must provide to ARGO your Apple Push Notifications Authentication Key. You can create it in Developer Apple.

Finally you need to call BearSDK.shared.registerDevice(withFcmToken token: String) with the FCM token. The FCM token can be retrieved in the func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) method:

extension AppDelegate: MessagingDelegate {

    public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
        BearSDK.shared.registerDevice(withFcmToken: fcmToken)
    }
}

To request APN token you have to execute:

UNUserNotificationCenter.current()
    .requestAuthorization(options: [.badge, .alert , .sound]) { (granted, error) in
        guard granted else { return }
        DispatchQueue.main.async {
            UIApplication.shared.registerForRemoteNotifications()
        }
}

This way the FCM token will be linked to the device id assigned at ARGO Backend. You can retrieve this device id in your application by calling BearSDK.shared.deviceId method.