Batch iOS apps
Step-by-step instructions to migrate your iOS app from Batch to WonderPush
Migrating to WonderPush is easy, in most cases all you have to do is add WonderPush to your app and publish a new version to the AppStore.
When users install the new version, they will automatically be added to WonderPush.
This guide will help you remove Batch from your app, add WonderPush, and show you how to import your existing Batch users into WonderPush. Please note that this last step is usually unnecessary as users installing the new version of your app will automatically be imported to WonderPush.
Shipping WonderPush in a new version of your app
Step 1. Removing the Batch Notification Extension
In your Xcode project General tab, select the RichNotificationsExtension
target and click Edit / Delete.
Select the RichNotificationsExtension
folder from the left column and choose Edit / Delete. When asked if you want to remove the references or the files choose Move to trash.
Step 2. Removing the Batch SDK
If you're using CocoaPods
Open your Podfile
and remove the reference to the Batch
pod:
pod 'Batch', '~> 1.13'
If you're using Carthage
Open your Cartfile
and remove this line:
github "BatchLabs/ios-sdk"
If you've made a manual integration
Select Batch.embeddedframework
and choose Edit / Delete. When asked if you want to remove the references or the files choose Move to trash.
Step 3. Clean your AppDelegate
Open your AppDelegate file and remove the following chunks:
import Batch
@import Batch;
Batch.start(withAPIKey: "YOUR_BATCH_API_KEY")
BatchPush.requestNotificationAuthorization()
[Batch startWithAPIKey:@"YOUR_BATCH_API_KEY"];
[BatchPush requestNotificationAuthorization];
Also remove any other code that calls the Batch
library within your entire app's codebase.
Step 4. Add WonderPush
Follow our iOS Quickstart guide to add WonderPush to your app, and publish a new version. Users that update their app will automatically appear in your WonderPush dashboard.
Importing your subscribers into WonderPush
Importing your existing subscribers into WonderPush will allow you to reach all of them via WonderPush right from the start.
Please note that you can usually skip this step and simply wait for your users to update their app.
Step 1. Export your push tokens from Batch
Unfortunately, batch does not let you export your push tokens yourself but you can contact them.
Step 2. Import your subscribers into WonderPush
Take note of your Access Token which can be found on the Management API section of the settings.
For every push token, call the Create or update an installation method of our Management API by adapting the following snippet with:
- an
INSTALLATION_ID
that must be an hexadecimal string (if you're unsure what to put here, you can use the push token itself), YOUR_APPLICATION_ACCESS_TOKEN
with the Access Token you've just taken note of,PUSH_TOKEN
with the push token.
curl -XPOST https://management-api.wonderpush.com/v1/installations/INSTALLATION_ID \
-d accessToken=YOUR_APPLICATION_ACCESS_TOKEN \
-d userId= \
-d overwrite=false \
-d body='{"pushToken":{"data":"PUSH_TOKEN"},"device":{"platform":"iOS"}}'
Please note that if you have lots of subscribers to import, you can use the /batch method of our API to create multiple installations in one call :
curl -XPOST https://management-api.wonderpush.com/v1/batch \
-d accessToken=YOUR_APPLICATION_ACCESS_TOKEN \
-d body='{"requests":[{"method":"POST","path":"/v1/installations/INSTALLATION_ID_1","args":{"userId":"","overwrite":true},"body":{"pushToken":{"data":"PUSH_TOKEN_1"},"device":{"platform":"iOS"}}},{"method":"POST","path":"/v1/installations/INSTALLATION_ID_2","args":{"userId":"","overwrite":true},"body":{"pushToken":{"data":"PUSH_TOKEN_2"},"device":{"platform":"iOS"}}}]}'
That's it!
You can go to your dashboard segments page and see the newly created installations in the All users segment.
Updated over 2 years ago