OneSignal iOS apps
Step-by-step instructions to migrate your iOS app from OneSignal 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 OneSignal from your app, add WonderPush, and show you how to import your existing OneSignal 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 OneSignal Notification Extension
In your Xcode project General tab, select the OneSignalNotificationServiceExtension
target and click Edit / Delete.
Select the OneSignalNotificationServiceExtension
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 OneSignal pod
Open your Podfile
and remove the reference to the OneSignal
pod:
pod 'OneSignal', '>= 2.6.2', '< 3.0'
Also remove this chunk:
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignal', '>= 2.6.2', '< 3.0'
end
Step 3. Clean your AppDelegate
Open your AppDelegate file and remove the following chunks:
import OneSignal
#import <OneSignal/OneSignal.h>
let onesignalInitSettings = [kOSSettingsKeyAutoPrompt: false]
// Replace 'YOUR_APP_ID' with your OneSignal App ID.
OneSignal.initWithLaunchOptions(launchOptions,
appId: "YOUR_ONESIGNAL_APP_ID",
handleNotificationAction: nil,
settings: onesignalInitSettings)
OneSignal.inFocusDisplayType = OSNotificationDisplayType.notification;
// Recommend moving the below line to prompt for push after informing the user about
// how your app will use them.
OneSignal.promptForPushNotifications(userResponse: { accepted in
print("User accepted notifications: \(accepted)")
})
[OneSignal initWithLaunchOptions:launchOptions
appId:@"YOUR_ONESIGNAL_APP_ID"
handleNotificationAction:nil
settings:@{kOSSettingsKeyAutoPrompt: @false}];
OneSignal.inFocusDisplayType = OSNotificationDisplayTypeNotification;
// Recommend moving the below line to prompt for push after informing the user about
// how your app will use them.
[OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) {
NSLog(@"User accepted notifications: %d", accepted);
}];
Also remove any other code that calls the OneSignal
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
We've developed a simple script to import your iOS OneSignal subscribers into WonderPush, here's how to use it.
Please note that this script simply imports push tokens into WonderPush, and does not import extra user information such as personal info or tags. If you wish to import these, you should:
- replace OneSignal
addTag
calls in your app with calls to our putProperties method,- use our Management REST API along with OneSignal's CSV export feature.
Step 1. Create a segment for iOS users in OneSignal
Go to your OneSignal dashboard, select your app then click on Users then New segment.
Create a new segment named iOS
(the name is important and case-sensitive) like this:
Step 2. Download our import script
On a Mac computer, open Terminal and paste the following:
curl -O https://gist.githubusercontent.com/stephanejais/6b205288834cd8c77763c807b8a9286a/raw/45652f594aa1be557488379b7bab792ddd310a34/wonderpush-import-onesignal.bash
Step 3. Execute the import script
Go to your WonderPush dashboard and take note of your Access Token from the API Credentials page.
Go to your OneSignal dashboard, select your app, then Settings / Keys & IDs and take note of your ONESIGNAL APP ID and REST API KEY.
In the same Terminal window where your downloaded the import script, paste the following command and adapt WONDERPUSH_ACCESS_TOKEN
, ONESIGNAL_API_KEY
and ONESIGNAL_APP_ID
:
bash wonderpush-import-onesignal.bash --wonderpush-access-token WONDERPUSH_ACCESS_TOKEN --onesignal-api-key ONESIGNAL_API_KEY --onesignal-app-id ONESIGNAL_APP_ID
That's it!
The script will export your OneSignal subscribers, then import then 100 by 100 into WonderPush, which might take a little while depending on how many subscribers you have.
Once the script has finished, you can go to your dashboard segments page and see the newly created installations in the All users segment.
Updated over 2 years ago