Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
dwfliplet authored Apr 22, 2024
2 parents 4e562fb + 7feb2d5 commit a546c63
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 1,140 deletions.
8 changes: 0 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,5 @@
],
"globals": {
"Vue": true
},
"rules": {
"no-new": 0,
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}]
}
}
13 changes: 12 additions & 1 deletion dist/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

668 changes: 2 additions & 666 deletions js/interface.js

Large diffs are not rendered by default.

66 changes: 0 additions & 66 deletions js/interface.templates.js

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions js/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ Fliplet.Widget.register('PushNotifications', function () {
* and add the event handlers on it
*/
var push = Fliplet.User.getPushNotificationInstance(data);

if (push) {
if (subscriptionId) {
if (subscriptionDetails.token) {
push.on('registration', function(data) {
push.on('registration', function (data) {
if (data.registrationId === subscriptionDetails.token) {
return; // token hasn't changed
}
Expand Down Expand Up @@ -95,8 +96,10 @@ Fliplet.Widget.register('PushNotifications', function () {
if (data.additionalData) {
if (data.additionalData.foreground) {
handleForegroundNotification(data);

return;
}

/**
* background notifications seem to open the application quite fast
* and sometimes the transition is not applied
Expand All @@ -113,6 +116,7 @@ Fliplet.Widget.register('PushNotifications', function () {
});
}
}

return push;
}

Expand Down Expand Up @@ -141,11 +145,10 @@ Fliplet.Widget.register('PushNotifications', function () {
});
}

if (Fliplet.Env.get('interact')
|| (Fliplet.Env.is('web') && Fliplet.Env.get('mode') === 'preview')) {
if (Fliplet.Env.get('interact')) {
return Promise.reject({
code: -1,
message: 'Push notifications are not supported in Fliplet Studio.'
message: 'Push notifications are not supported in Fliplet Studio while in edit mode.'
});
}

Expand Down Expand Up @@ -180,8 +183,9 @@ Fliplet.Widget.register('PushNotifications', function () {
});
}).then(function (displayPopup) {
if (!displayPopup) {
return subscribeUser().then(function(subscriptionId) {
return subscribeUser().then(function (subscriptionId) {
initPushNotifications(subscriptionId);

return subscriptionId;
});
}
Expand All @@ -194,6 +198,7 @@ Fliplet.Widget.register('PushNotifications', function () {
return subscribeUser();
}).then(function (subscriptionId) {
initPushNotifications(subscriptionId);

return subscriptionId;
}).then(resolve).catch(function (err) {
console.error(err);
Expand Down Expand Up @@ -262,16 +267,17 @@ Fliplet.Widget.register('PushNotifications', function () {
ask: ask,
reset: function () {
askPromise = undefined;

return Fliplet.Storage.remove(key);
},
isConfigured: isConfigured
};
});

Fliplet.Widget.instance('push-notification', function() {
Fliplet.Widget.instance('push-notification', function () {
var $container = $(this);

Fliplet().then(function() {
Fliplet().then(function () {
$container.translate();
});
});
24 changes: 12 additions & 12 deletions src/components/NotificationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ import {
const defaultAudience = '';
const defaultScope = [];
const pushNotificationErrorTypes = {
NoSubscriptions: 'One or more devices are not subscribed to receive this push notification.',
NotRegistered: 'One or more devices are not subscribed to receive this push notification, or the app might be uninstalled.',
InvalidProviderToken: 'The APN Key ID, push certificate, or Team ID are not valid. Please verify your settings.',
MismatchSenderId: 'The Sender ID provided for the push notification service does not match the ID used user subscribed to push notifications. Please ensure that the Sender ID is consistent and corresponds to the one used for subscribing to push notifications.',
DeviceTokenNotForTopic: 'The target bundle identifier does not match with the one used the subscribed devices.',
TopicDisallowed: 'The target bundle identifier doesn\'t match what some subscribed devices are using.',
GCMNotSet: 'Firebase push notifications (for Android devices) haven\'t been set up.',
APNNotSet: 'Apple push notifications (for iOS devices) haven\'t been set up.'
};
const defaultPushNotificationErrorMessage = 'Unknown error. Please contact support.';
export default {
data() {
Expand Down Expand Up @@ -299,21 +310,10 @@ export default {
: Math.round((acceptedCount) / (totalCount) * 100)
};
const errorTypes = {
NoSubscriptions: 'One or more devices are not subscribed to receive this push notification.',
NotRegistered: 'One or more devices are not subscribed to receive this push notification, or the app might be uninstalled.',
InvalidProviderToken: 'The APN Key ID, push certificate, or Team ID is incorrect. Please verify your settings.',
MismatchSenderId: 'User is subscribed to push notifications for a Sender ID that doesn\'t match the configured Sender ID.',
DeviceTokenNotForTopic: 'The target bundle identifier doesn\'t match what some subscribed devices are using.',
TopicDisallowed: 'The target bundle identifier doesn\'t match what some subscribed devices are using.',
GCMNotSet: 'Firebase push notifications (for Android devices) haven\'t been set up.',
APNNotSet: 'Apple push notifications (for iOS devices) haven\'t been set up.'
};
data.errors = _.orderBy(_.map(_.keys(allErrors), (type) => {
return {
type,
description: errorTypes[type],
description: pushNotificationErrorTypes[type] || defaultPushNotificationErrorMessage,
count: allErrors[type]
};
}), ['count'], ['desc']);
Expand Down
18 changes: 9 additions & 9 deletions src/libs/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
// https://stackoverflow.com/questions/22724898/settimezoneoffset-globally-for-whole-script/40518781
Date.prototype.timezoneOffset = new Date().getTimezoneOffset();

Date.setTimezoneOffset = function (timezoneOffset) {
Date.setTimezoneOffset = function(timezoneOffset) {
this.prototype.timezoneOffset = timezoneOffset;

return this;
};

Date.getTimezoneOffset = function () {
Date.getTimezoneOffset = function() {
return this.prototype.timezoneOffset;
};

Date.prototype.setTimezoneOffset = function (timezoneOffset) {
Date.prototype.setTimezoneOffset = function(timezoneOffset) {
this.timezoneOffset = timezoneOffset;

return this;
};

Date.prototype.getTimezoneOffset = function () {
Date.prototype.getTimezoneOffset = function() {
return this.timezoneOffset;
};

Date.prototype.toString = function () {
Date.prototype.toString = function() {
var offsetDate;
var offsetTime;

Expand All @@ -34,9 +34,9 @@ Date.prototype.toString = function () {
return offsetDate.toUTCString();
};

['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear', 'Year', 'Day'].forEach((function () {
return function (key) {
Date.prototype['get' + key] = function () {
['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear', 'Year', 'Day'].forEach((function() {
return function(key) {
Date.prototype['get' + key] = function() {
var offsetDate;
var offsetTime;

Expand All @@ -46,7 +46,7 @@ Date.prototype.toString = function () {
return offsetDate['getUTC' + key]();
};

Date.prototype['set' + key] = function (value) {
Date.prototype['set' + key] = function(value) {
var offsetDate;
var offsetTime;
var time;
Expand Down
4 changes: 0 additions & 4 deletions templates/loading.interface.hbs

This file was deleted.

119 changes: 0 additions & 119 deletions templates/newNotification.interface.hbs

This file was deleted.

Loading

0 comments on commit a546c63

Please sign in to comment.