Closed asangadev closed 6 years ago
Hello @asangadev ,
To disable automatic iOS push registration, please follow https://www.braze.com/documentation/Cordova/iOS/#removing-automatic-push-setup-ios. To manually register for iOS push notifications, follow the steps outlined via https://www.braze.com/documentation/iOS/#step-3-register-for-push-notifications.
Let us know if these steps work for you.
Hi @radixde,
Thanks for getting back to us. Is there any Javascript method (that we can trigger the core function)? We would like to control this via Javascript.
Cheers!
We do not have a way to manually request the iOS push permission via the plugin. You'll have to modify the plugin to allow for the manual registration to occur via Javascript.
Hi guys,
We are switching from a different service provider to Braze. Our app is built on Phonegap and we are currently doing all the tests on our trial version of Braze.
Manual push call: Is this something you guys can help with? May be a plugin update?
Currently we have our app live on both Play and App stores. So we have push enabled devices with our current system. After we migrated to Braze, what will happen to the people who already accepted the push permission? Are they automatically registered under our new Braze account?
Please advise.
You'll have to email support@braze.com to guide you through the push registration migration.
For the manual push call:
Clone the cordova plugin to make these plugin changes and import that modified version into your project.
Remove the automatic prompt from https://github.com/Appboy/appboy-cordova-sdk/blob/master/src/ios/AppboyPlugin.m#L45-L65
Update the AppboyPlugin.js to add a show push prompt
or equivalent method. I.e.
AppboyPlugin.prototype.iosShowPushPrompt = function () {
cordova.exec(null, null, "AppboyPlugin", "iosShowPushPrompt", []);
}
Update the AppboyPlugin.m
file to implement the iosShowPushPrompt
method.
- (void)iosShowPushPrompt:(CDVInvokedUrlCommand *)command {
UIUserNotificationType notificationSettingTypes = (UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound);
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
// If the delegate hasn't been set yet, set it here in the plugin
if (center.delegate == nil) {
center.delegate = [UIApplication sharedApplication].delegate;
}
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
NSLog(@"Permission granted.");
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationSettingTypes categories:nil];
[[UIApplication sharedApplication] registerForRemoteNotifications];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: notificationSettingTypes];
}
}
iosShowPushPrompt
on the appboy plugin via javascript to show the push promptI have setup a separate repo: https://github.com/asangadev/appboy-cordova-sdk/commit/0a5800b3868434da37713ba6bd3d564e09b455aa
Cheers!
Hi @radixdev ,
Could you please help us with below?
Hi @radixdev,
Platform iOS: We are planning to ask the push registration permission with a button tap. So basically we want to disable the automatic feature that comes with the plugin.
We have found below:
On iOS we can trigger this only once, so we need to ask for this permission on the right section of the app.
Can we simply call (what parameters we can pass?): registerAppboyPushMessages()
Please advise.