1

I am facing issues with plugin of one signal in Intel XDK, BUT Intel XDK is very development friendly tool so before i transfer i project in android studio to build app , i want to add push notification by one signal into it give complete ness to app.

I want step 2 of this question?

How to import An Existing Intel XDK Project in Android Studio

Community
  • 1
  • 1

1 Answers1

1

no need to open your app on android studio. Just use Firebase and Onesignal for your push notifications.

first create your project and add Onesignal plugin to your project using thirdparty plugins tab and add github repo links

enter image description here

1) Now go to OneSignal and make an account if you don't have one. Now click "Add a new app" square.

2) Now name your app what ever you want. We will name it as "PushFirebase".

3) Now you have to go to Firebase and go to it's console which is in right hand corner button.

4) Click Add new project and pick a name and your region.Create your project.

5) Now click project settings which is inside wheel icon, then go to "Cloud Messaging" tab. Copy both Server key and Sender ID items.

6) Now go back to OneSignal and paste Sender Key inside Google Server API Key text box. And paste Sender ID inside Google Project Number text box .

7) Now select your SDK platform what ever you want, for this pick Phonegap, Cordova, Ionic, Intel XDK option and Click Next which is the final step.

8) Now make sure to copy Your App ID which is what we need for our Cordova mobile application.

9) Now let's go to OneSignal documentation for Cordova SDK and copy the following code which is related to Cordova App.

        // Add to index.js or the first page that loads with your app.
        // For Intel XDK and please add this to your app.js.                
            document.addEventListener('deviceready', function () {
              // Enable to debug issues.
              // window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

              var notificationOpenedCallback = function(jsonData) {
                console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
              };

              window.plugins.OneSignal
                .startInit("YOUR_APPID")
                .handleNotificationOpened(notificationOpenedCallback)
                .endInit();

              // Call syncHashedEmail anywhere in your app if you have the user's email.
              // This improves the effectiveness of OneSignal's "best-time" notification scheduling feature.
              // window.plugins.OneSignal.syncHashedEmail(userEmail);
            }, false);`

10) Now paste the code which we pasted from the documentation(9th step) by creating new js file ex- push.js inside js folder in folder structure.

11) Now Include it inside index.html

 `<script type="text/javascript" src="js/push.js"></script>`

12) Now replace the .startInit("YOUR_APPID") with what you have copied from 8th step.

13) Make sure that you have finished all steps in OneSignal. Now go back to OneSignal home and Click New Push Notification.

AVI
  • 5,516
  • 5
  • 29
  • 38