@codeleap/mobile 4.2.8 → 4.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Registry.js +28 -53
- package/dist/Registry.js.map +1 -1
- package/dist/components/ActionIcon/index.js +27 -67
- package/dist/components/ActionIcon/index.js.map +1 -1
- package/dist/components/ActionIcon/styles.js +1 -2
- package/dist/components/ActionIcon/types.js +1 -2
- package/dist/components/ActivityIndicator/index.js +22 -62
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/ActivityIndicator/styles.js +1 -2
- package/dist/components/ActivityIndicator/types.js +1 -2
- package/dist/components/Autocomplete/index.js +73 -121
- package/dist/components/Autocomplete/index.js.map +1 -1
- package/dist/components/Autocomplete/styles.js +1 -2
- package/dist/components/Autocomplete/types.js +1 -2
- package/dist/components/Avatar/index.js +49 -90
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Avatar/styles.js +1 -2
- package/dist/components/Avatar/types.js +1 -2
- package/dist/components/AvatarGroup/index.js +30 -75
- package/dist/components/AvatarGroup/index.js.map +1 -1
- package/dist/components/AvatarGroup/styles.js +1 -2
- package/dist/components/AvatarGroup/types.js +1 -2
- package/dist/components/Backdrop/index.js +26 -66
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Backdrop/styles.js +1 -2
- package/dist/components/Backdrop/types.js +1 -2
- package/dist/components/Badge/index.js +44 -85
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/styles.js +1 -2
- package/dist/components/Badge/types.js +1 -2
- package/dist/components/Button/index.js +49 -98
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/styles.js +1 -2
- package/dist/components/Button/types.js +1 -2
- package/dist/components/Calendar/index.js +27 -68
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Calendar/types.d.ts +1 -2
- package/dist/components/Calendar/types.js +1 -2
- package/dist/components/Checkbox/index.js +52 -85
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/styles.js +1 -2
- package/dist/components/Checkbox/types.js +1 -2
- package/dist/components/DatePickerModal/index.js +61 -113
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/DatePickerModal/styles.js +1 -2
- package/dist/components/DatePickerModal/types.js +1 -2
- package/dist/components/EmptyPlaceholder/index.js +40 -69
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +1 -2
- package/dist/components/EmptyPlaceholder/types.js +1 -2
- package/dist/components/FileInput/index.js +112 -178
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/FileInput/types.js +1 -2
- package/dist/components/Grid/index.js +47 -97
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Grid/styles.js +1 -2
- package/dist/components/Grid/types.js +1 -2
- package/dist/components/Icon/index.js +34 -75
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Icon/styles.js +1 -2
- package/dist/components/Icon/types.js +1 -2
- package/dist/components/Image/index.js +53 -96
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/Image/styles.js +1 -2
- package/dist/components/Image/types.js +1 -2
- package/dist/components/ImageView/Spotlight.js +75 -131
- package/dist/components/ImageView/Spotlight.js.map +1 -1
- package/dist/components/ImageView/component.js +8 -15
- package/dist/components/ImageView/component.js.map +1 -1
- package/dist/components/ImageView/index.js +2 -18
- package/dist/components/ImageView/index.js.map +1 -1
- package/dist/components/InputBase/index.js +35 -75
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/styles.d.ts +3 -3
- package/dist/components/InputBase/styles.js +49 -50
- package/dist/components/InputBase/styles.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +1 -0
- package/dist/components/InputBase/types.js +1 -2
- package/dist/components/InputBase/utils.js +4 -19
- package/dist/components/InputBase/utils.js.map +1 -1
- package/dist/components/List/index.js +46 -86
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/styles.js +1 -2
- package/dist/components/List/types.js +1 -2
- package/dist/components/LoadingOverlay/index.js +28 -66
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/LoadingOverlay/styles.js +1 -2
- package/dist/components/LoadingOverlay/types.js +1 -2
- package/dist/components/Modal/index.js +77 -113
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.js +1 -2
- package/dist/components/Modal/types.js +1 -2
- package/dist/components/Navigation/Navigation.js +23 -66
- package/dist/components/Navigation/Navigation.js.map +1 -1
- package/dist/components/Navigation/constants.js +7 -10
- package/dist/components/Navigation/constants.js.map +1 -1
- package/dist/components/Navigation/index.js +3 -19
- package/dist/components/Navigation/index.js.map +1 -1
- package/dist/components/Navigation/types.js +1 -2
- package/dist/components/Navigation/utils.js +24 -59
- package/dist/components/Navigation/utils.js.map +1 -1
- package/dist/components/NumberIncrement/index.js +132 -165
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/styles.js +1 -2
- package/dist/components/NumberIncrement/types.d.ts +2 -2
- package/dist/components/NumberIncrement/types.js +1 -2
- package/dist/components/NumberIncrement/utils.js +8 -12
- package/dist/components/NumberIncrement/utils.js.map +1 -1
- package/dist/components/Pager/PagerDots.js +17 -54
- package/dist/components/Pager/PagerDots.js.map +1 -1
- package/dist/components/Pager/index.js +43 -97
- package/dist/components/Pager/index.js.map +1 -1
- package/dist/components/Pager/styles.js +1 -2
- package/dist/components/Pager/types.js +1 -2
- package/dist/components/PaginationIndicator/index.js +23 -38
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/styles.js +1 -2
- package/dist/components/PaginationIndicator/types.js +1 -2
- package/dist/components/PlacesAutocomplete/index.js +55 -106
- package/dist/components/PlacesAutocomplete/index.js.map +1 -1
- package/dist/components/PlacesAutocomplete/styles.js +1 -2
- package/dist/components/PlacesAutocomplete/types.js +1 -2
- package/dist/components/RadioInput/index.js +46 -84
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/styles.js +1 -2
- package/dist/components/RadioInput/types.js +1 -2
- package/dist/components/RefreshControl/index.js +22 -63
- package/dist/components/RefreshControl/index.js.map +1 -1
- package/dist/components/RefreshControl/styles.js +1 -2
- package/dist/components/RefreshControl/types.js +1 -2
- package/dist/components/Scroll/index.js +33 -81
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Scroll/styles.js +1 -2
- package/dist/components/Scroll/types.js +1 -2
- package/dist/components/SearchInput/index.js +22 -69
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/context.d.ts +6 -0
- package/dist/components/SectionFilters/context.js +4 -8
- package/dist/components/SectionFilters/context.js.map +1 -1
- package/dist/components/SectionFilters/index.js +33 -76
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/types.js +1 -2
- package/dist/components/SectionFilters/useSectionFilters.d.ts +3 -0
- package/dist/components/SectionFilters/useSectionFilters.js +71 -73
- package/dist/components/SectionFilters/useSectionFilters.js.map +1 -1
- package/dist/components/Sections/index.d.ts +8 -8
- package/dist/components/Sections/index.js +61 -106
- package/dist/components/Sections/index.js.map +1 -1
- package/dist/components/Sections/styles.d.ts +1 -1
- package/dist/components/Sections/styles.js +1 -2
- package/dist/components/Sections/types.js +1 -2
- package/dist/components/SegmentedControl/Option.js +13 -31
- package/dist/components/SegmentedControl/Option.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +71 -114
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/styles.js +1 -2
- package/dist/components/SegmentedControl/types.js +1 -2
- package/dist/components/Select/index.js +94 -157
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +1 -2
- package/dist/components/Select/types.js +1 -2
- package/dist/components/Slider/index.js +89 -129
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/styles.d.ts +0 -6
- package/dist/components/Slider/styles.js +1 -2
- package/dist/components/Slider/types.js +1 -2
- package/dist/components/SortablePhotos/index.js +58 -91
- package/dist/components/SortablePhotos/index.js.map +1 -1
- package/dist/components/SortablePhotos/styles.js +1 -2
- package/dist/components/SortablePhotos/types.js +1 -2
- package/dist/components/SortablePhotos/useSortablePhotos.js +93 -157
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
- package/dist/components/Switch/index.js +51 -84
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/styles.js +1 -2
- package/dist/components/Switch/types.js +1 -2
- package/dist/components/Text/index.js +40 -88
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/styles.js +1 -2
- package/dist/components/Text/types.js +1 -2
- package/dist/components/TextInput/index.js +83 -131
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.js +1 -2
- package/dist/components/TextInput/types.js +1 -2
- package/dist/components/Touchable/index.js +69 -122
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/styles.js +1 -2
- package/dist/components/Touchable/types.js +1 -2
- package/dist/components/View/index.js +19 -51
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/styles.js +1 -2
- package/dist/components/View/types.js +1 -2
- package/dist/components/components.js +43 -59
- package/dist/components/components.js.map +1 -1
- package/dist/hooks/index.js +7 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +8 -43
- package/dist/index.js.map +1 -1
- package/dist/modules/PressableRipple/index.js +2 -8
- package/dist/modules/PressableRipple/index.js.map +1 -1
- package/dist/modules/PressableRipple/ripple.js +125 -163
- package/dist/modules/PressableRipple/ripple.js.map +1 -1
- package/dist/modules/PressableRipple/styles.js +9 -20
- package/dist/modules/PressableRipple/styles.js.map +1 -1
- package/dist/modules/PressableRipple/type.js +1 -2
- package/dist/modules/reactNavigation.js +10 -21
- package/dist/modules/reactNavigation.js.map +1 -1
- package/dist/modules/textInputMask.js +3 -20
- package/dist/modules/textInputMask.js.map +1 -1
- package/dist/modules/types/textInputMask.js +1 -2
- package/dist/types/index.js +1 -17
- package/dist/types/index.js.map +1 -1
- package/dist/types/utility.js +1 -2
- package/dist/utils/KeyboardAware/context.js +5 -14
- package/dist/utils/KeyboardAware/context.js.map +1 -1
- package/dist/utils/KeyboardAware/index.js +3 -19
- package/dist/utils/KeyboardAware/index.js.map +1 -1
- package/dist/utils/KeyboardAware/keyboardHooks.js +36 -41
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
- package/dist/utils/KeyboardAware/types.js +1 -2
- package/dist/utils/KeyboardAware/types.js.map +1 -1
- package/dist/utils/ModalManager/components.js +24 -54
- package/dist/utils/ModalManager/components.js.map +1 -1
- package/dist/utils/ModalManager/context.js +94 -89
- package/dist/utils/ModalManager/context.js.map +1 -1
- package/dist/utils/ModalManager/index.js +7 -10
- package/dist/utils/ModalManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/index.js +115 -245
- package/dist/utils/NotificationManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/types.js +1 -2
- package/dist/utils/OSAlert.js +32 -48
- package/dist/utils/OSAlert.js.map +1 -1
- package/dist/utils/PermissionManager/context.js +138 -255
- package/dist/utils/PermissionManager/context.js.map +1 -1
- package/dist/utils/PermissionManager/index.js +2 -8
- package/dist/utils/PermissionManager/index.js.map +1 -1
- package/dist/utils/PermissionManager/types.js +1 -2
- package/dist/utils/StorageManager.js +39 -46
- package/dist/utils/StorageManager.js.map +1 -1
- package/dist/utils/Subscription.js +30 -54
- package/dist/utils/Subscription.js.map +1 -1
- package/dist/utils/deprecated/notifications.js +143 -250
- package/dist/utils/deprecated/notifications.js.map +1 -1
- package/dist/utils/hooks.js +101 -120
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/index.js +14 -43
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/input.js +15 -19
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/locale.js +5 -9
- package/dist/utils/locale.js.map +1 -1
- package/dist/utils/misc.js +25 -40
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/theme.js +24 -33
- package/dist/utils/theme.js.map +1 -1
- package/dist/utils/useQueryListRefresh.js +16 -26
- package/dist/utils/useQueryListRefresh.js.map +1 -1
- package/package.json +6 -6
- package/package.json.bak +2 -2
- package/src/components/Calendar/types.ts +3 -3
- package/src/components/InputBase/styles.ts +35 -23
- package/src/components/InputBase/types.ts +1 -0
- package/src/components/NumberIncrement/index.tsx +8 -2
- package/src/components/NumberIncrement/types.ts +3 -3
- package/src/components/RadioInput/index.tsx +4 -0
- package/src/components/SectionFilters/useSectionFilters.tsx +31 -1
- package/src/components/Sections/index.tsx +3 -2
- package/src/components/Sections/styles.ts +2 -2
- package/src/components/Slider/index.tsx +9 -1
- package/src/components/Slider/styles.ts +0 -6
- package/src/components/TextInput/index.tsx +5 -0
|
@@ -1,274 +1,167 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.NotificationManager = void 0;
|
|
40
|
-
var common_1 = require("@codeleap/common");
|
|
1
|
+
import { silentLogger } from '@codeleap/common';
|
|
41
2
|
// @ts-ignore
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
3
|
+
import { firebase } from '@react-native-firebase/messaging';
|
|
4
|
+
const messaging = firebase.messaging;
|
|
5
|
+
const MODULE = 'Notifications';
|
|
45
6
|
/**
|
|
46
7
|
* Class responsible for the notification system
|
|
47
8
|
*
|
|
48
9
|
* @deprecated Use the most updated version
|
|
49
10
|
* @note check the documentation to make the migration
|
|
50
11
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
12
|
+
export class NotificationManager {
|
|
13
|
+
logger;
|
|
14
|
+
autoHandleInitialNotification;
|
|
15
|
+
stateChangeListeners = [];
|
|
16
|
+
messageListeners = [];
|
|
17
|
+
_initialized = false;
|
|
18
|
+
unsubscribeFromMessage = null;
|
|
19
|
+
unsubscribeFromBackgroundMessage = null;
|
|
20
|
+
unsubscribeFromPress = null;
|
|
21
|
+
_currentToken = null;
|
|
22
|
+
_initialNoficationHandled = false;
|
|
23
|
+
constructor(logger = silentLogger, autoHandleInitialNotification = true) {
|
|
55
24
|
this.logger = logger;
|
|
56
25
|
this.autoHandleInitialNotification = autoHandleInitialNotification;
|
|
57
|
-
this.stateChangeListeners = [];
|
|
58
|
-
this.messageListeners = [];
|
|
59
|
-
this._initialized = false;
|
|
60
|
-
this.unsubscribeFromMessage = null;
|
|
61
|
-
this.unsubscribeFromBackgroundMessage = null;
|
|
62
|
-
this.unsubscribeFromPress = null;
|
|
63
|
-
this._currentToken = null;
|
|
64
|
-
this._initialNoficationHandled = false;
|
|
65
26
|
}
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.initialized = true;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
this.currentToken = null;
|
|
96
|
-
this.initialized = false;
|
|
97
|
-
}
|
|
98
|
-
messaging().onTokenRefresh(function (newToken) {
|
|
99
|
-
// logger.log('onTokenRefresh', { newToken }, MODULE)
|
|
100
|
-
if (token_1) {
|
|
101
|
-
_this.currentToken = newToken;
|
|
102
|
-
_this.initialized = true;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
_this.currentToken = null;
|
|
106
|
-
_this.initialized = false;
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return [3 /*break*/, 5];
|
|
110
|
-
case 4:
|
|
111
|
-
e_1 = _a.sent();
|
|
112
|
-
this.logger.error('Failed to initialize notification services', e_1, MODULE);
|
|
113
|
-
return [3 /*break*/, 5];
|
|
114
|
-
case 5: return [2 /*return*/];
|
|
27
|
+
async init() {
|
|
28
|
+
// return
|
|
29
|
+
if (this.initialized)
|
|
30
|
+
return;
|
|
31
|
+
try {
|
|
32
|
+
await messaging().registerDeviceForRemoteMessages();
|
|
33
|
+
// logger.log('firebase registeted', '', MODULE)
|
|
34
|
+
const token = await messaging().getToken();
|
|
35
|
+
// logger.log('init token', { token }, MODULE)
|
|
36
|
+
if (token) {
|
|
37
|
+
this.currentToken = token;
|
|
38
|
+
this.initialized = true;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.currentToken = null;
|
|
42
|
+
this.initialized = false;
|
|
43
|
+
}
|
|
44
|
+
messaging().onTokenRefresh(newToken => {
|
|
45
|
+
// logger.log('onTokenRefresh', { newToken }, MODULE)
|
|
46
|
+
if (token) {
|
|
47
|
+
this.currentToken = newToken;
|
|
48
|
+
this.initialized = true;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.currentToken = null;
|
|
52
|
+
this.initialized = false;
|
|
115
53
|
}
|
|
116
54
|
});
|
|
55
|
+
// logger.log('init success', {}, MODULE)
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
this.logger.error('Failed to initialize notification services', e, MODULE);
|
|
59
|
+
// OSAlert.error({ title: 'Failed to initialize notification services' })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async deinit() {
|
|
63
|
+
[
|
|
64
|
+
this.unsubscribeFromMessage,
|
|
65
|
+
this.unsubscribeFromBackgroundMessage,
|
|
66
|
+
this.unsubscribeFromPress,
|
|
67
|
+
].forEach(unsubscribe => {
|
|
68
|
+
if (unsubscribe) {
|
|
69
|
+
unsubscribe();
|
|
70
|
+
}
|
|
117
71
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
72
|
+
this.initialized = false;
|
|
73
|
+
}
|
|
74
|
+
async handleNotification(args) {
|
|
75
|
+
for (const listener of this.messageListeners) {
|
|
76
|
+
await listener(args.data, args.type);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
get currentToken() {
|
|
80
|
+
return this._currentToken;
|
|
81
|
+
}
|
|
82
|
+
set currentToken(token) {
|
|
83
|
+
this._currentToken = token;
|
|
84
|
+
this.triggerStateChange();
|
|
85
|
+
}
|
|
86
|
+
get initialized() {
|
|
87
|
+
return this._initialized;
|
|
88
|
+
}
|
|
89
|
+
set initialized(to) {
|
|
90
|
+
if (to) {
|
|
91
|
+
this.logger.info('Initialized', '', MODULE);
|
|
92
|
+
this.unsubscribeFromMessage = messaging().onMessage((msg) => {
|
|
93
|
+
this.handleNotification({
|
|
94
|
+
data: msg,
|
|
95
|
+
type: 'foreground',
|
|
130
96
|
});
|
|
131
|
-
this.initialized = false;
|
|
132
|
-
return [2 /*return*/];
|
|
133
97
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return __generator(this, function (_b) {
|
|
140
|
-
switch (_b.label) {
|
|
141
|
-
case 0:
|
|
142
|
-
_i = 0, _a = this.messageListeners;
|
|
143
|
-
_b.label = 1;
|
|
144
|
-
case 1:
|
|
145
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
146
|
-
listener = _a[_i];
|
|
147
|
-
return [4 /*yield*/, listener(args.data, args.type)];
|
|
148
|
-
case 2:
|
|
149
|
-
_b.sent();
|
|
150
|
-
_b.label = 3;
|
|
151
|
-
case 3:
|
|
152
|
-
_i++;
|
|
153
|
-
return [3 /*break*/, 1];
|
|
154
|
-
case 4: return [2 /*return*/];
|
|
155
|
-
}
|
|
98
|
+
this.unsubscribeFromBackgroundMessage = messaging().setBackgroundMessageHandler(async (msg) => {
|
|
99
|
+
this.handleNotification({
|
|
100
|
+
data: msg,
|
|
101
|
+
type: 'background',
|
|
102
|
+
});
|
|
156
103
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
set: function (token) {
|
|
164
|
-
this._currentToken = token;
|
|
165
|
-
this.triggerStateChange();
|
|
166
|
-
},
|
|
167
|
-
enumerable: false,
|
|
168
|
-
configurable: true
|
|
169
|
-
});
|
|
170
|
-
Object.defineProperty(NotificationManager.prototype, "initialized", {
|
|
171
|
-
get: function () {
|
|
172
|
-
return this._initialized;
|
|
173
|
-
},
|
|
174
|
-
set: function (to) {
|
|
175
|
-
var _this = this;
|
|
176
|
-
if (to) {
|
|
177
|
-
this.logger.info('Initialized', '', MODULE);
|
|
178
|
-
this.unsubscribeFromMessage = messaging().onMessage(function (msg) {
|
|
179
|
-
_this.handleNotification({
|
|
180
|
-
data: msg,
|
|
181
|
-
type: 'foreground',
|
|
182
|
-
});
|
|
104
|
+
this.unsubscribeFromPress = messaging().onNotificationOpenedApp(msg => {
|
|
105
|
+
this.logger.info('Notification press', msg, MODULE);
|
|
106
|
+
this.handleNotification({
|
|
107
|
+
data: msg,
|
|
108
|
+
type: 'press',
|
|
183
109
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
_this.handleNotification({
|
|
196
|
-
data: msg,
|
|
197
|
-
type: 'press',
|
|
110
|
+
});
|
|
111
|
+
if (!this._initialNoficationHandled && this.autoHandleInitialNotification) {
|
|
112
|
+
this.getInitialNotification().then(msg => {
|
|
113
|
+
if (!msg.data)
|
|
114
|
+
return;
|
|
115
|
+
this.logger.info('Notification initial', msg, MODULE);
|
|
116
|
+
this.handleNotification(msg).then(() => {
|
|
117
|
+
this._initialNoficationHandled = true;
|
|
118
|
+
}).catch(e => {
|
|
119
|
+
this._initialNoficationHandled = true;
|
|
120
|
+
this.logger.error('Error handling initial notification', e, MODULE);
|
|
198
121
|
});
|
|
199
122
|
});
|
|
200
|
-
if (!this._initialNoficationHandled && this.autoHandleInitialNotification) {
|
|
201
|
-
this.getInitialNotification().then(function (msg) {
|
|
202
|
-
if (!msg.data)
|
|
203
|
-
return;
|
|
204
|
-
_this.logger.info('Notification initial', msg, MODULE);
|
|
205
|
-
_this.handleNotification(msg).then(function () {
|
|
206
|
-
_this._initialNoficationHandled = true;
|
|
207
|
-
}).catch(function (e) {
|
|
208
|
-
_this._initialNoficationHandled = true;
|
|
209
|
-
_this.logger.error('Error handling initial notification', e, MODULE);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
this.unsubscribeFromMessage = null;
|
|
216
|
-
this.unsubscribeFromBackgroundMessage = null;
|
|
217
|
-
this.unsubscribeFromPress = null;
|
|
218
|
-
this.logger.info('Deinitialized', '', MODULE);
|
|
219
123
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.unsubscribeFromMessage = null;
|
|
127
|
+
this.unsubscribeFromBackgroundMessage = null;
|
|
128
|
+
this.unsubscribeFromPress = null;
|
|
129
|
+
this.logger.info('Deinitialized', '', MODULE);
|
|
130
|
+
}
|
|
131
|
+
this._initialized = to;
|
|
132
|
+
this.triggerStateChange();
|
|
133
|
+
}
|
|
134
|
+
onNotification(handler) {
|
|
135
|
+
const newLen = this.messageListeners.push(handler);
|
|
136
|
+
return () => {
|
|
137
|
+
this.messageListeners.splice(newLen - 1, 1);
|
|
231
138
|
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
l(_this._initialized, _this.currentToken);
|
|
139
|
+
}
|
|
140
|
+
triggerStateChange() {
|
|
141
|
+
this.stateChangeListeners.forEach(l => {
|
|
142
|
+
l(this._initialized, this.currentToken);
|
|
237
143
|
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
_this.stateChangeListeners.splice(newLen - 1, 1);
|
|
144
|
+
}
|
|
145
|
+
onStateChange(handler) {
|
|
146
|
+
const newLen = this.stateChangeListeners.push(handler);
|
|
147
|
+
return () => {
|
|
148
|
+
this.stateChangeListeners.splice(newLen - 1, 1);
|
|
244
149
|
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return [2 /*return*/, {
|
|
263
|
-
data: null,
|
|
264
|
-
type: 'initial',
|
|
265
|
-
}];
|
|
266
|
-
case 3: return [2 /*return*/];
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
|
-
return NotificationManager;
|
|
272
|
-
}());
|
|
273
|
-
exports.NotificationManager = NotificationManager;
|
|
150
|
+
}
|
|
151
|
+
async getInitialNotification() {
|
|
152
|
+
try {
|
|
153
|
+
const msg = await messaging().getInitialNotification();
|
|
154
|
+
return {
|
|
155
|
+
data: msg,
|
|
156
|
+
type: 'initial',
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
return {
|
|
161
|
+
data: null,
|
|
162
|
+
type: 'initial',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
274
167
|
//# sourceMappingURL=notifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/utils/deprecated/notifications.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/utils/deprecated/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC7D,aAAa;AACb,OAAO,EAAE,QAAQ,EAA0B,MAAM,kCAAkC,CAAA;AAEnF,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;AAEpC,MAAM,MAAM,GAAG,eAAe,CAAA;AAc9B;;;;;EAKE;AACF,MAAM,OAAO,mBAAmB;IAkBR;IAA8B;IAhBlD,oBAAoB,GAAqC,EAAE,CAAA;IAE3D,gBAAgB,GAAyB,EAAE,CAAA;IAE3C,YAAY,GAAG,KAAK,CAAA;IAEpB,sBAAsB,GAAG,IAAI,CAAA;IAE7B,gCAAgC,GAAG,IAAI,CAAA;IAEvC,oBAAoB,GAAG,IAAI,CAAA;IAE3B,aAAa,GAAG,IAAI,CAAA;IAEpB,yBAAyB,GAAG,KAAK,CAAA;IAEjC,YAAoB,SAAS,YAAY,EAAS,gCAAgC,IAAI;QAAlE,WAAM,GAAN,MAAM,CAAe;QAAS,kCAA6B,GAA7B,6BAA6B,CAAO;IACtF,CAAC;IAED,KAAK,CAAC,IAAI;QACR,SAAS;QACT,IAAI,IAA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