notifly-sdk 1.0.7 → 1.0.8

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 +13 -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,14 @@ 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
+ function _initialize(prjId, userName, password) {
45
49
  try {
46
- messaging().requestPermission();
50
+
51
+ await messaging().requestPermission();
47
52
 
48
53
  messaging().onNotificationOpenedApp(async (remoteMessage) => {
49
54
  const link = remoteMessage.data?.link
@@ -72,6 +77,9 @@ exports.initialize = async function (prjId, userName, password) {
72
77
  AsyncStorage.setItem('notiflyUserName', userName),
73
78
  AsyncStorage.setItem('notiflyUserPassword', password),
74
79
  ])
80
+
81
+ await _sessionStart();
82
+
75
83
  } catch (err) {
76
84
  console.warn("[Notifly]: ", err);
77
85
  }
@@ -227,6 +235,7 @@ async function logEvent(eventName, eventParams, segmentation_event_param_keys =
227
235
 
228
236
  const response = await _apiCall("https://12lnng07q2.execute-api.ap-northeast-2.amazonaws.com/prod/records", requestOptions);
229
237
  const result = JSON.parse(response)
238
+ console.log('api', result)
230
239
  if (result.message == "The incoming token has expired") {
231
240
  const [userName, password] = await Promise.all([AsyncStorage.getItem('notiflyUserName'), AsyncStorage.getItem('notiflyUserPassword')])
232
241
  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.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {