Skip to content

Delay asking for system permission (iOS)

By default StreetHawk library register push notification and location service when initialize the engine, making system permission dialog for notification and location promote when App first launch. In case you may wish to delay asking the user for those permission, you can add the code be as shown below.

  • Native platform
StreetHawk.isDefaultNotificationEnabled = NO;  //make registerInstallForApp: not register for user notification, delay for later time.
StreetHawk.isDefaultLocationServiceEnabled = NO;  //make registerInstallForApp: not trigger location service, delay for later time.

//do [StreetHawk registerInstallForApp...] and other things.

StreetHawk.isNotificationEnabled = YES;  //later when ready to register for user notification, call this.
StreetHawk.isLocationServiceEnabled = YES;  //later when ready to asking for location service, call this.

Swift code:

SHApp.sharedInstance().isDefaultNotificationEnabled = false  //make registerInstallForApp: not register for user notification, delay for later time.
SHApp.sharedInstance().isDefaultLocationServiceEnabled = false  //make registerInstallForApp: not trigger location service, delay for later time.

//do SHApp.sharedInstance().registerInstallForApp(...) and other things.

SHApp.sharedInstance().isNotificationEnabled = true  //later when ready to register for user notification, call this.
SHApp.sharedInstance().isLocationServiceEnabled = true;  //later when ready to asking for location service, call this.

Refer to:

var sh = cordova.require("com.streethawk.core.Streethawk");
sh.shSetDefaultNotificationService(false); //make streethawkinit not register for user notification, delay for later time.
sh.shSetDefaultLocationService(false); //make streethawkinit not enable location service, delay for later time.

//do streethawkinit and other things.

sh.shSetNotificationEnabled(true);  //later when ready to register for user notification, call this.
sh.shSetLocationEnabled(true);  //later when ready to enable location service, call this.

Refer to Phonegap document.

  • Xamarin platform
SHPush.instance().isDefaultNotificationEnabled = false;  //make streethawkinit not register for user notification, delay for later time.
//In location aspect, SHBeacon, SHLocation and SHGeofence is same.
SHBeacon.instance().isDefaultLocationServiceEnabled = false;  //make streethawkinit not trigger location service, delay for later time.
//or
SHLocation.instance().isDefaultLocationServiceEnabled = false;  //make streethawkinit not trigger location service, delay for later time.
//or
SHGeofence.instance().isDefaultLocationServiceEnabled = false;  //make streethawkinit not trigger location service, delay for later time.

//do SHApp.instance ().streethawkinit (); and other things.

SHPush.instance().isNotificationEnabled = true;  //later when ready to register for user notification, call this.
SHBeacon.instance().isLocationServiceEnabled = true;  //later when ready to asking for location service, call this.
//or
SHLocation.instance().isLocationServiceEnabled = true;  //later when ready to asking for location service, call this.
//or
SHGeofence.instance().isLocationServiceEnabled = true;  //later when ready to asking for location service, call this.

Refer to: