T
T
The Cyprinus
Search…
Utility Methods

Set DeviceToken

The Roam SDK is capable of sending push notifications to your users. Check here to get the device token.
Swift
Objective-C
1
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
2
Roam.setDeviceToken(deviceToken)
3
}
Copied!
1
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
2
[Roam setDeviceToken:deviceToken];
3
}
Copied!

Check Location Permission

Check whether your app has location permission.
Swift
Objective-C
1
Roam.isLocationEnabled()
Copied!
1
[Roam isLocationEnabled];
Copied!

Location Permission Status

By using the locationPermissionStatus method you can check the location permission status.
Swift
Objective-C
1
Roam.locationPermissionStatus()
Copied!
1
[Roam locationPermissionStatus];
Copied!
notDetermined = 0
restricted = 1
denied = 2
authorizedAlways = 3
authorizedWhenInUse = 4

Request Location Permission

Check whether your App has location permission.
Swift
Objective-C
1
Roam.requestLocation()
Copied!
1
[Roam requestLocation];
Copied!

Check Location Tracking

Check whether location tracking is started or not. This method returns a boolean value.
Swift
Objective-C
1
Roam.isLocationTracking()
Copied!
1
[Roam isLocationTracking];
Copied!

Current Location

Get the current location of the user. You can set the accuracy between 5 to 100 meters (default is 10).
Swift
Objective-C
1
Roam.getCurrentLocation(accuracy) { (location, error) in
2
//location?.coordinate.latitude
3
//location?.coordinate.longitude
4
//location?.altitude
5
// error?.code
6
// error?.message
7
}
Copied!
1
[Roam getCurrentLocation:<#(NSInteger)#> handler:^(CLLocation * location, GeoSparkError * error) {
2
//location?.coordinate.latitude
3
//location?.coordinate.longitude
4
//location?.altitude
5
// error?.code
6
// error?.message
7
}];
Copied!

Update Current Location

Using the updateCurrentLocation method, you can update user current location. You can set the accuracy between 5 to 100 meters (default is 10).
Swift
Objective-C
1
Roam.updateCurrentLocation(accuracy)
Copied!
1
[Roam updateCurrentLocation:accuracy];
Copied!
This method should be used only if you need to update the current location of the device with better accuracy. Using this method consistently will consume more battery.
The higher the accuracy the longer the response time time. In some cases it could take up to 30 seconds depending on the GPS signal strength.

Notification Opened Handler

By using this method inside the Notification delegate method you can track the campaign's impressions and counts.
Swift
Objective-C
1
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
2
{
3
Roam.notificationOpenedHandler(response)
4
completionHandler()
5
}
Copied!
1
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{
2
[Roam notificationOpenedHandler:response];
3
}
Copied!
Last modified 3mo ago