Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

cordova.js needed or not? #305

Closed contactwahyu closed 5 years ago

contactwahyu commented 5 years ago

Hi This is probably a silly question, but I need to make sure, do we need to include cordova.js in index.html?

I'm building using Framework7 and it seems has different way to handle anything. I put these following code in app.js

$$(document).on('DOMContentLoaded', function(){ app.dialog.alert('Device Ready!'); var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification"); // Should be called before pushwoosh.onDeviceReady document.addEventListener('push-notification', function(event) { var notification = event.notification; // handle push open here app.dialog.alert('Hello!'); }); // Initialize Pushwoosh. This will trigger all pending push notifications on start. pushwoosh.onDeviceReady({ appid: "XXXXX-XXXXX", projectid: "xxxxxxxxxxx", serviceName: "MPNS_SERVICE_NAME" });
});

However, it just only display "Device Ready!" and nothing after that. Any ideas would be highly appreciated... Thanks.

wfhm commented 5 years ago

@contactwahyu

To make it work you should do the following:

1) add <script src=cordova.js></> to your index.html - this line already persists in framework7 samples, it is commented out, so you just need to uncomment it. 2) add init event handler and initialize Pushwoosh plugin inside it.