So i am trying to integrate a onesignal push notification to my F7 app, according to the docs i have to do this
For Cordova SDK
cordova plugin add onesignal-cordova-plugin --save
-> Done
Then this step
3.0 Add the following to the bottom of the first Javascript file that loads with your app. This is <project-dir>/www/js/index.js
for most Cordova projects.
// Add to index.js or the first page that loads with your app.
receivedEvent: function(id) {
//START ONESIGNAL CODE
//Remove this method to stop OneSignal Debugging
window.plugins.OneSignal.setLogLevel({logLevel: 6, visualLevel: 0});
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
// Set your iOS Settings
var iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = false;
iosSettings["kOSSettingsKeyInAppLaunchURL"] = false;
window.plugins.OneSignal
.startInit("YOUR_ONESIGNAL_APP_ID")
.handleNotificationOpened(notificationOpenedCallback)
.iOSSettings(iosSettings)
.inFocusDisplaying(window.plugins.OneSignal.OSInFocusDisplayOption.Notification)
.endInit();
// The promptForPushNotificationsWithUserResponse function will show the iOS push notification prompt. We recommend removing the following code and instead using an In-App Message to prompt for notification permission (See step 6)
window.plugins.OneSignal.promptForPushNotificationsWithUserResponse(function(accepted) {
console.log("User accepted notifications: " + accepted);
});
//END ONESIGNAL CODE
}
How do i integrate it proper?