*iOS 13 Permissions Wizard
Integration needed
New call
Implemented new class RPPermissionsWizard. Please, call it instance by returnInstance and use launchWithFinish for Objective-c or launch for Swift method with callback.
Objective-c:
[[RPPermissionsWizard returnInstance] launchWithFinish:^(BOOL showWizzard) {
}];
Swift:
RPPermissionsWizard.returnInstance().launch(finish: { showWizzard in
})
Add all setup call of RaxelPulse SDK to callback method
Objective-c:
[[RPPermissionsWizard returnInstance] launchWithFinish:^(BOOL showWizzard)
{ [RPEntry initializeWithRequestingPermissions:YES];
[RPEntry instance].virtualDeviceToken = @"_____";
.... etc
}];
Swift:
RPPermissionsWizard.returnInstance().launch(finish: { _ in
RPEntry.initialize(withRequestingPermissions: true)
let token = NSString(string: "______")
RPEntry.instance().virtualDeviceToken = token
let options = launchOptions ?? [:]
RPEntry.application(application, didFinishLaunchingWithOptions:
options)
.... etc
})
Add Push Notifications call to this call back after init of RaxelPulse
Objective-c:
[[RPPermissionsWizard returnInstance] launchWithFinish:^(BOOL showWizzard) {
[RPEntry initializeWithRequestingPermissions:YES];
[RPEntry instance].virtualDeviceToken = @"_____";
.... etc
}];
Swift:
RPPermissionsWizard.returnInstance().launch(finish: { _ in
RPEntry.initialize(withRequestingPermissions: true)
let token = NSString(string: "______")
RPEntry.instance().virtualDeviceToken = token
let options = launchOptions ?? [:]
RPEntry.application(application, didFinishLaunchingWithOptions:
options)
.... etc
})
or you can use RPPermissionsWizard handlers
Objective-c:
[[RPPermissionsWizard returnInstance] setupHandlersWithUserNotificationResponce:^(BOOL granted, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"error while requesting notification permission. Error code
%li, error description %@",
error.code, error.description);
}
NSLog(@"receiving notification is granted: %d", granted);
} motionManagerResponce:^(BOOL granted, NSError * _Nullable error) {
NSLog(@"receiving motion is granted: %d", granted);
} locationManagerResponce:^(CLAuthorizationStatus status) {
NSLog(@"receiving location status: %d", status);
}];
Swift:
RPPermissionsWizard.returnInstance().setupHandlers(
userNotificationResponce: { (granted, error) in
DispatchQueue.main.async {
if granted {
UIApplication.shared.registerForRemoteNotifications()
observer.onNext(true)
} else {
observer.onNext(false)
}
observer.onCompleted()
}
},
motionManagerResponce: { (granted, error) in
},
locationManagerResponce: { (status) in
})
Required Permissions Granted
Added isAllRequiredPermissionsGranted property for get state of SDK permissions needed. Objective-c:
BOOL isAllFine = RPEntry.isAllRequiredPermissionsGranted()
Swift:
BOOL isAllFine = [RPEntry isAllRequiredPermissionsGranted];
Permissions Wizard Customisation
If you not changed next property Wizard used default values from itself.
Implemented new class RPSettings. Please, call it instance by returnInstance and use property:
wizardBgColor - background color of screen view
wizardMaintextColor - main text color
wizardAlertTextColor - main text color in example alert
wizardAlertButtonColor - button text color in alert
wizardAlertActiveButtonColor - active button text color in alert
wizardAlertActiveButtonBgColor - active button background color in alert
wizardAlertCorners - alert corner radius in CGFloat
Default Values:
.White
public var wizardBgColor : UIColor = UIColor.groupTableViewBackground
public var wizardMaintextColor : UIColor = UIColor.black
public var wizardAlertBackgroundColor : UIColor = UIColor.white
public var wizardAlertTextColor : UIColor = UIColor(hex: "6F8593")
public var wizardAlertButtonTextColor : UIColor = UIColor(hex: "0984ff")
public var wizardAlertActiveButtonTextColor: UIColor = UIColor.white
public var wizardAlertActiveButtonBgColor : UIColor = UIColor(hex: "FF9300")
public var wizardAlertCorners : CGFloat = 7.0
public var wizardNextButtonBgColor : UIColor = UIColor(red:
0.10980392156862745, green: 0.10980392156862745, blue: 0.11764705882352941,
alpha: 1.0)
public var wizardNextButtonTextColor : UIColor = UIColor.white
.Dark worked only when you not customising following alert colors:
wizardAlertBackgroundColor wizardAlertTextColor wizardAlertActiveButtonBgColor
.Dark style used next Default:
wizardAlertBackgroundColor = UIColor(red: 0.17254901960784313, green: 0.17254901960784313, blue: 0.1803921568627451, alpha: 1.0)
wizardAlertTextColor = UIColor.white
wizardAlertActiveButtonBgColor = UIColor(hex: "8e8e93")
wizardAlertActiveButtonTextColor = UIColor(hex: "0984ff")
How to use Settings:
Objective-c:
[RPSettings returnInstance].wizardAlertActiveButtonBgColor =
[UIColor colorWithRed: 0.79
green : 0.22
blue : 0.17
alpha : 1.0];
Swift:
RPSettings.returnInstance.wizardAlertActiveButtonBgColor = UIColor.red
Custom text on Wizard pages:
Objective-c:
NSMutableAttributedString *firstButton = [[NSMutableAttributedString alloc] initWithString:@"Ok"];
NSMutableAttributedString *secondButton = [[NSMutableAttributedString alloc] initWithString:@"Cancel"];
NSArray<NSMutableAttributedString *> *buttonsList = [[NSArray alloc] initWithObjects:firstButton, secondButton, nil];
RPPageTexts *whileInUsePage = [[RPPageTexts alloc] initWithPageText:[[NSMutableAttributedString alloc] initWithString:@"Attention Required!\n\nYou will receive a popup shortly. This popup will aks you for access to your location even when you are not using the app.\n\nPlease, choose “Always While Using App” for <appName> to automatically detect when you start a trip."] alertText:[[NSMutableAttributedString alloc] initWithString:@"Allow <appName> to access your location?\n\nWe use location service for evaluating your driving manner. Be enabling “Always While Using App” on location, the app will be able to automatically determine when you have started and ended a drive"] buttonsText:buttonsList selected:1];
RPPageTexts *motionPage = [[RPPageTexts alloc] initWithPageText:[[NSMutableAttributedString alloc] initWithString:@"Attention Required!\n\nThen, You will receive a popup to grant us access to your Motion & Fitness activity. We need this information to create a driving score.\n\nPlease, choose “OK” for <appName> to grant us access to Motion & Fitness activity."] alertText:[[NSMutableAttributedString alloc] initWithString:@"<appName> Would Like to Access Your Motion & Fitness Activity\n\nWe use motion sensors for evaluating your driving manner"] buttonsText:buttonsList selected:1];
RPPageTexts *pushPage = [[RPPageTexts alloc] initWithPageText:[[NSMutableAttributedString alloc] initWithString:@"Attention Required!\n\nAs the next step, You will receive a popup to grant us rights to send you important notifications. You are always able to turn off notifications by categories in the App settings menu.\n\nPlease, choose “Allow” for <appName> to keep you informed on important events."] alertText:[[NSMutableAttributedString alloc] initWithString:@"<appName> Would Like to Send You Notifications\n\nNotifications may include alerts, sounds and icon badges. These can be configured in Settings"] buttonsText:buttonsList selected:1];
RPPageTexts *alwaysPage = [[RPPageTexts alloc] initWithPageText:[[NSMutableAttributedString alloc] initWithString:@"Attention Required!\n\nYou will receive a popup shortly for <appName> to have access to your location even when you are not using the app.\n\nFor the app to work properly\n“Change to Always Allow”"] alertText:[[NSMutableAttributedString alloc] initWithString:@"Allow <appName> to also access your location even when you are not using the app?\n\nWe use location service for generating a driving score. Be enabling “Always” on location, the app will be able to automatically determine when you have started and ended a drive"] buttonsText:buttonsList selected:1];
NSArray<RPPageTexts *> *customPages = [[NSArray alloc] initWithObjects:whileInUsePage, motionPage, pushPage, alwaysPage, nil];
[RPSettings returnInstance].wizardPages = customPages;
Swift:
let whileInUsePage = RPPageTexts(pageText: NSMutableAttributedString(string: "Attention Required!\n\nYou will receive a popup shortly. This popup will aks you for access to your location even when you are not using the app.\n\nPlease, choose “Always While Using App” for <appName> to automatically detect when you start a trip."), alertText: NSMutableAttributedString(string: "Allow <appName> to access your location?\n\nWe use location service for evaluating your driving manner. Be enabling “Always While Using App” on location, the app will be able to automatically determine when you have started and ended a drive"), buttonsText: [NSMutableAttributedString(string: "Always While Using App”), NSMutableAttributedString(string: "Allow Once”), NSMutableAttributedString(string: "Don’t Allow”)], selected: 0)
let motionPage = RPPageTexts(pageText: NSMutableAttributedString(string: "Attention Required!\n\nThen, You will receive a popup to grant us access to your Motion & Fitness activity. We need this information to create a driving score.\n\nPlease, choose “OK” for <appName> to grant us access to Motion & Fitness activity."), alertText: NSMutableAttributedString(string: "<appName> Would Like to Access Your Motion & Fitness Activity\n\nWe use motion sensors for evaluating your driving manner"), buttonsText: [NSMutableAttributedString(string: "Don’t Allow”), NSMutableAttributedString(string: "OK”)], selected: 1)
let pushPage = RPPageTexts(pageText: NSMutableAttributedString(string: "Attention Required!\n\nAs the next step, You will receive a popup to grant us rights to send you important notifications. You are always able to turn off notifications by categories in the App settings menu.\n\nPlease, choose “Allow” for <appName> to keep you informed on important events."), alertText: NSMutableAttributedString(string: "<appName> Would Like to Send You Notifications\n\nNotifications may include alerts, sounds and icon badges. These can be configured in Settings"), buttonsText: [NSMutableAttributedString(string: "Don’t Allow”), NSMutableAttributedString(string: "Allow”)], selected: 1)
let alwaysPage = RPPageTexts(pageText: NSMutableAttributedString(string: "Attention Required!\n\nYou will receive a popup shortly for <appName> to have access to your location even when you are not using the app.\n\nFor the app to work properly\n“Change to Always Allow”"), alertText: NSMutableAttributedString(string: "Allow <appName> to also access your location even when you are not using the app?\n\nWe use location service for generating a driving score. Be enabling “Always” on location, the app will be able to automatically determine when you have started and ended a drive"), buttonsText: [NSMutableAttributedString(string: "Keep Only While Using”), NSMutableAttributedString(string: "Change to Always Allow”)], selected: 1)
RPSettings.returnInstance().wizardPages = [whileInUsePage, motionPage, pushPage, alwaysPage]
Last updated