Reputation: 15039
I have an old app developed with Appcelerator - Titanium SDK using FCM Push notifications.
The device token that I get on the device is:
"baf48325219887fdb5929ac5d9495d8897a48f0b77a1c9c23131097e51dc1234"
Because Appcelerator is deprecated, I want to know how to get the FCM token so I can still notify the devices even if Appcelerator has been deprecated.
** UPDATE **
This is the code for getting the deviceToken:
exports.requestDeviceToken = function() {
if (Ti.Platform.model.indexOf('Simulator') !== -1 || Ti.Platform.model.indexOf('Emulator') !== -1) {
return;
}
var params = {
callback:pushNotificationCallback,
success:deviceTokenSuccess,
error: deviceTokenError,
};
var types = [
Ti.Network.NOTIFICATION_TYPE_BADGE,
Ti.Network.NOTIFICATION_TYPE_ALERT,
Ti.Network.NOTIFICATION_TYPE_SOUND
];
if (Ti.Platform.name == 'android') {
var CloudPush = require('ti.cloudpush');
// Initialize the module
CloudPush.retrieveDeviceToken({
success: deviceTokenSuccess,
error: deviceTokenError,
});
CloudPush.addEventListener('callback', pushNotificationCallback);
}
else {
if (Ti.Platform.name != "android" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
Ti.API.info('registering push notifications iOS > 8');
Ti.Network.registerForPushNotifications(params);
Ti.App.iOS.registerUserNotificationSettings({types:types});
}
else {
params.types = types;
Ti.Network.registerForPushNotifications(params);
}
}
};
Any clue?
Upvotes: 0
Views: 144
Reputation: 4055
There is https://github.com/hansemannn/titanium-firebase-cloud-messaging available since 2017 that you can use to connect your app to FCM. Using it for years and it's working without any issue.
Transfering an existing app takes around 30mins.
...
if (OS_IOS) {
const FirebaseCore = require('firebase.core');
fc.configure();
}
const FirebaseCloudMessaging = require('firebase.cloudmessaging');
if (OS_ANDROID) {
FirebaseCloudMessaging.registerForPushNotifications();
}
...
as a short example. A fulll example with connection to the Android channels, how to get the token (iOS and Android) is available in the repo at https://github.com/hansemannn/titanium-firebase-cloud-messaging#example
Upvotes: 0