MCPcopy Create free account
hub / github.com/CommE2E/comm / componentDidMount

Method componentDidMount

native/push/push-handler.react.js:165–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163 iosNotificationEventSubscriptions: Array<EventSubscription> = [];
164
165 componentDidMount() {
166 this.appStarted = Date.now();
167 this.lifecycleSubscription = addLifecycleListener(
168 this.handleAppStateChange,
169 );
170 this.onForeground();
171 if (Platform.OS === 'ios') {
172 const commIOSNotificationsEventEmitter =
173 getCommIOSNotificationsEventEmitter();
174 this.iosNotificationEventSubscriptions.push(
175 commIOSNotificationsEventEmitter.addListener(
176 CommIOSNotifications.getConstants()
177 .REMOTE_NOTIFICATIONS_REGISTERED_EVENT,
178 registration =>
179 this.registerPushPermissions(registration?.deviceToken),
180 ),
181 commIOSNotificationsEventEmitter.addListener(
182 CommIOSNotifications.getConstants()
183 .REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT,
184 this.failedToRegisterPushPermissionsIOS,
185 ),
186 commIOSNotificationsEventEmitter.addListener(
187 CommIOSNotifications.getConstants()
188 .NOTIFICATION_RECEIVED_FOREGROUND_EVENT,
189 this.iosForegroundNotificationReceived,
190 ),
191 commIOSNotificationsEventEmitter.addListener(
192 CommIOSNotifications.getConstants().NOTIFICATION_OPENED_EVENT,
193 this.iosNotificationOpened,
194 ),
195 commIOSNotificationsEventEmitter.addListener(
196 CommIOSNotifications.getConstants()
197 .NOTIFICATION_RECEIVED_BACKGROUND_EVENT,
198 this.iosBackgroundNotificationReceived,
199 ),
200 );
201 } else if (Platform.OS === 'android') {
202 CommAndroidNotifications.createChannel(
203 androidNotificationChannelID,
204 'Default',
205 CommAndroidNotifications.getConstants().NOTIFICATIONS_IMPORTANCE_HIGH,
206 'Comm notifications channel',
207 );
208 const commAndroidNotificationsEventEmitter =
209 getCommAndroidNotificationsEventEmitter();
210 this.androidNotificationsEventSubscriptions.push(
211 commAndroidNotificationsEventEmitter.addListener(
212 CommAndroidNotifications.getConstants()
213 .COMM_ANDROID_NOTIFICATIONS_TOKEN,
214 this.handleAndroidDeviceToken,
215 ),
216 commAndroidNotificationsEventEmitter.addListener(
217 CommAndroidNotifications.getConstants()
218 .COMM_ANDROID_NOTIFICATIONS_MESSAGE,
219 this.androidMessageReceived,
220 ),
221 commAndroidNotificationsEventEmitter.addListener(
222 CommAndroidNotifications.getConstants()

Callers

nothing calls this directly

Calls 9

onForegroundMethod · 0.95
updateBadgeCountMethod · 0.95
addLifecycleListenerFunction · 0.90
pushMethod · 0.80
createChannelMethod · 0.80
addListenerMethod · 0.65
getConstantsMethod · 0.45

Tested by

no test coverage detected