-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloud Push, recommend approach / examples #1106
Comments
For Android we have developed the plugin https://github.com/eclipsesource/tabris-plugin-firebase. It allows you to use firebase cloud messaging with Tabris.js (2.x). For iOS there are several cordova plugins available that support the Push Message mechanics. |
Ok, great to know. so the firebase plugin wouldn't work for iOS? can you suggest the list of compatible cordova plugins please? |
This plugin works with iOS https://github.com/eclipsesource/phonegap-plugin-push. However it has been modified and only supports APNS. The GCM part has been removed. JS API remained unchanged. |
if you use Pushwoosh, I updated their cordova plugin to work with tabris. It seems to work well on iOS and Android although I have not tested some of their advanced features (location tracking etc) https://github.com/spatialdatalogic/pushwoosh-phonegap-plugin |
@bFlood Would you happen to have an example |
@camstuart That is correct. You don't have to wait for the device ready callback. The plugin is available instantly. |
plugin.xml <plugin name="pushwoosh-cordova-plugin" spec="https://github.com/spatialdatalogic/pushwoosh-phonegap-plugin" /> and like @mpost mentioned above, plugins are available immediately, so you can call this from anywhere Server.prototype.initPushwoosh = function() {
try {
var pushNotification = cordova.require( 'pushwoosh-cordova-plugin.PushNotification' );
var self = this;
if (util.isAndroid()) {
//============
//Android
//set push notifications handler
document.addEventListener('push-notification', function (event) {
var title = event.notification.title;
var userData = event.notification.userdata;
if (typeof(userData) != "undefined") {
var module = util.safeGet(userData, "module", "");
var type = util.safeGet(userData, "type", "");
var iid = util.safeGet(userData, "iid", "");
self.processPushNotification(module, type, iid);
}
});
//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", pw_appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady(
{projectid: "1234567890", pw_appid: "12345-67890"}
);
//register for pushes
//fast Google Pixel device caused issue here, can functions get executed out of order?
//delay the registerDevice call to fix the issue
window.setTimeout(function() {
pushNotification.registerDevice(
function (status) {
util.log(status);
var pushToken = status.pushToken;
util.setItem("_pndt", pushToken);
},
function (status) {
util.log(['failed to register ', status]);
}
);
}, 200);
} else {
//============
//iOS
//set push notification callback before we initialize the plugin
document.addEventListener('push-notification', function (event) {
//get the notification payload
var notification = event.notification;
//TODO - figure out what comes through iOS
util.log(notification);
});
//initialize the plugin
pushNotification.onDeviceReady({pw_appid: "12345-67890"});
//register for pushes
pushNotification.registerDevice(
function (status) {
var deviceToken = status['pushToken'];
util.log('registerDevice: ' + deviceToken);
util.setItem("_pndt", deviceToken);
},
function (status) {
util.log(['failed to register ', status]);
}
);
}
} catch (e) {
util.log("PUSH NOTIFICATIONS failed to initialize");
}
}; |
Fantastic @bFlood thanks for your great example, really appreciated. I have it working now. In my case I removed the outer callback Server.prototype.initPushwoosh = function() { because And the event notification response data on iOS looks like this: {
foreground:true,
onStart:false,
ios:{
aps:{
alert:"This is the push message text",
sound:"default",
badge:0
},
p:"7"
},
message:"This is the push message text"
} Mostly options selected in the push woosh UI |
great, glad it helped. Pushwoosh is extra money but it does make working with all push on all platforms a little easier IMO. cheers |
Closing this as resolved. Please reopen if you have any more issues. |
What's the recommended cloud messaging approach for Tabris.
CloudPush (http://developer.eclipsesource.com/tabris/docs/2.0/working/client-services/cloud-push/)
Seems fairly involved, requiring Xcode to set up an "application delegate"
And firebase cloud messaging support was not clear (platforms, Tabris version)
In the current day, what is the recommended approach? And is there a clear example or tutorial?
The text was updated successfully, but these errors were encountered: