notifly-sdk 1.0.7 → 1.0.9

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.
Files changed (2) hide show
  1. package/index.js +12 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import messaging from "@react-native-firebase/messaging";
2
- import { Linking, Platform } from 'react-native';
2
+ import { Linking, PermissionsAndroid, Platform } from 'react-native';
3
3
  import AsyncStorage from '@react-native-async-storage/async-storage';
4
4
  import rnDeviceInfo from 'react-native-device-info';
5
5
  import { v5 } from 'uuid';
@@ -24,7 +24,7 @@ exports.setUserId = async function (userID) {
24
24
  }
25
25
  }
26
26
 
27
- exports.sessionStart = async function () {
27
+ async function _sessionStart() {
28
28
  const apiLevel = rnDeviceInfo.getApiLevel(); // only android
29
29
  const brand = rnDeviceInfo.getBrand(); // apple samsung
30
30
  const model = rnDeviceInfo.getModel(); // 기종 SM-G960N or iPhone 8
@@ -41,9 +41,13 @@ exports.sessionStart = async function () {
41
41
  await logEvent("session_start", openAppEventParams, null, true)
42
42
  }
43
43
 
44
- exports.initialize = async function (prjId, userName, password) {
44
+ exports.initialize = function (prjId, userName, password) {
45
+ _initialize(prjId, userName, password);
46
+ }
47
+
48
+ async function _initialize(prjId, userName, password) {
45
49
  try {
46
- messaging().requestPermission();
50
+ await messaging().requestPermission();
47
51
 
48
52
  messaging().onNotificationOpenedApp(async (remoteMessage) => {
49
53
  const link = remoteMessage.data?.link
@@ -72,6 +76,9 @@ exports.initialize = async function (prjId, userName, password) {
72
76
  AsyncStorage.setItem('notiflyUserName', userName),
73
77
  AsyncStorage.setItem('notiflyUserPassword', password),
74
78
  ])
79
+
80
+ await _sessionStart();
81
+
75
82
  } catch (err) {
76
83
  console.warn("[Notifly]: ", err);
77
84
  }
@@ -227,6 +234,7 @@ async function logEvent(eventName, eventParams, segmentation_event_param_keys =
227
234
 
228
235
  const response = await _apiCall("https://12lnng07q2.execute-api.ap-northeast-2.amazonaws.com/prod/records", requestOptions);
229
236
  const result = JSON.parse(response)
237
+ console.log('api', result)
230
238
  if (result.message == "The incoming token has expired") {
231
239
  const [userName, password] = await Promise.all([AsyncStorage.getItem('notiflyUserName'), AsyncStorage.getItem('notiflyUserPassword')])
232
240
  const newToken = await getCognitoIdToken(userName, password);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notifly-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {