I'm using Intel-XDK to develope an app, I want to implement push notifications. I am using pushwoosh cordova plugin 3.6.15 After a successful build I install it on my device but the app is crushes. When I add the plugin but not using it it doesn't crush This is the code lines I add in order to use the plugin:

try { if (/(android)/i.test(navigator.userAgent)) { registerPushwooshAndroid(); } else if (/(iphone|ipad)/i.test(navigator.userAgent)) {

            }
        }
        catch (err) {
            alert(err.message);
        }

This is the implementation of PushwooshAndroid.js:

/ * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. /

function registerPushwooshAndroid() { var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");

//set push notifications handler
document.addEventListener('push-notification',
    function(event) {
        var title = event.notification.title;
        var userData = event.notification.userdata;

        //dump custom data to the console if it exists
        if (typeof(userData) != "undefined") {
            console.warn('user data: ' + JSON.stringify(userData));
        }

        //and show alert
        alert(title);

        //stopping geopushes
        //pushNotification.stopGeoPushes();
    }
);

//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({
    projectid: "My ProjectID",
    pw_appid: "My pw_appid"
});

//register for push notifications
pushNotification.registerDevice(
    function(token) {
        alert(token);
        //callback when pushwoosh is ready
        onPushwooshAndroidInitialized(token);
    },
    function(status) {
        alert("failed to register: " + status);
        console.warn(JSON.stringify(['failed to register ', status]));
    }
);

}

function onPushwooshAndroidInitialized(pushToken) { //output the token to the console console.warn('push token: ' + pushToken);

var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");

//if you need push token at a later time you can always get it from Pushwoosh plugin
pushNotification.getPushToken(
    function(token) {
        console.warn('push token: ' + token);
    }
);

//and HWID if you want to communicate with Pushwoosh API
pushNotification.getPushwooshHWID(
    function(token) {
        console.warn('Pushwoosh HWID: ' + token);
    }
);

pushNotification.getTags(
    function(tags) {
        console.warn('tags for the device: ' + JSON.stringify(tags));
    },
    function(error) {
        console.warn('get tags error: ' + JSON.stringify(error));
    }
);


//set multi notificaiton mode
//pushNotification.setMultiNotificationMode();
//pushNotification.setEnableLED(true);

//set single notification mode
//pushNotification.setSingleNotificationMode();

//disable sound and vibration
//pushNotification.setSoundType(1);
//pushNotification.setVibrateType(1);

pushNotification.setLightScreenOnNotification(false);

//setting list tags
//pushNotification.setTags({"MyTag":["hello", "world"]});

//settings tags
pushNotification.setTags({
        deviceName: "hello",
        deviceId: 10
    },
    function(status) {
        console.warn('setTags success');
    },
    function(status) {
        console.warn('setTags failed');
    }
);

//Pushwoosh Android specific method that cares for the battery
//pushNotification.startGeoPushes();

}

I include these js scripts in my index.html code too: <script src="js/app.js"></script> <script src="js/PushwooshAndroid.js"></script> <script src="js/PushwooshiOS.js"></script> <script src="js/PushwooshWP.js"></script> <script src="xdk/init-dev.js"></script>

You can get the APK from here: LINK Please assist me Another thing, I tried the pushwoosh tutorial project and it did not fail, I don't know why Thanks for your help

asked 11 Nov '15, 14:30
htvsoft's gravatar image

htvsoft
111

closed 26 Nov '15, 10:53

Benedict's gravatar image

Benedict
7127

The question has been closed for the following reason "Issue is not related to Pushwoosh. There's a conflict between different versions of Google Play Services libraries used in the project by two different plugins — Pushwoosh uses the latest version, AdMob — the outdated one." by Benedict 26 Nov '15, 10:53

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×326
×190
×30
×6

question asked: 11 Nov '15, 14:30

question was seen: 757 times

last updated: 26 Nov '15, 10:53