Skip to content

Commit

Permalink
Adding better support for IOS to use FCM (#453)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan authored May 25, 2024
1 parent 05353eb commit 6ba6c6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion routes/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exports.devicessendmessage = function (req, res) {
if (!error && sendMessageDevice) {
if (sendMessageDevice.fcmRegistration) {
firebase.sendNotification(sendMessageDevice.fcmRegistration, newNotification);
} else if (sendMessageDevice.deviceType == 'ios') {
} else if (sendMessageDevice.iosDeviceToken) {
appleSender.sendAppleNotification(sendMessageDevice.iosDeviceToken, message);
}
req.flash('info', 'Your message was sent');
Expand Down
5 changes: 4 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ Routes.prototype.setupAppRoutes = function (app) {
app.all('/api/v1/hidenotification/:id', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.hidenotification);
app.all('/api/v1/settings/notifications', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationssettingsget);

// Android app registration
// Android app registration (FCM)
app.all('/addAndroidRegistration*', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, fcmRegistrationService.registerAndroid);
// Apple app registration (FCM)
app.all('/addIosRegistration*', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, fcmRegistrationService.registerIos);
// Apple app registration (legacy)
app.all('/addAppleRegistration*', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, appleRegistrationService);
};

Expand Down
2 changes: 1 addition & 1 deletion socket-io.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function SocketIO(server, system) {
for (var i = 0; i < userDevices.length; i++) {
if (userDevices[i].fcmRegistration) {
fcmRegistrations.push(userDevices[i].fcmRegistration);
} else if (userDevices[i].deviceType === 'ios') {
} else if (userDevices[i].iosDeviceToken) {
iosDeviceTokens.push(userDevices[i].iosDeviceToken);
}
}
Expand Down

0 comments on commit 6ba6c6a

Please sign in to comment.