notifly-sdk 1.0.5 → 1.0.6

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 +1 -65
  2. package/package.json +1 -2
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import messaging from "@react-native-firebase/messaging";
2
- import notifee, { AndroidImportance } from "@notifee/react-native";
3
2
  import { Linking, Platform } from 'react-native';
4
3
  import AsyncStorage from '@react-native-async-storage/async-storage';
5
4
  import rnDeviceInfo from 'react-native-device-info';
@@ -59,82 +58,19 @@ exports.initialize = async function (prjId, userName, password) {
59
58
  Linking.openURL(remoteMessage.notification?.android?.link);
60
59
  }
61
60
  await logEvent("push_click", { "campaign_id": remoteMessage.data.campaign_id, "status": "quit" }, null, true);
62
- await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "quit" }, null, true);
63
-
64
61
  }
65
62
  });
66
63
 
67
- messaging().setBackgroundMessageHandler(async (remoteMessage) => {
68
- await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "background" }, null, true);
69
- return
70
- })
71
-
72
64
  await Promise.all([
73
65
  AsyncStorage.setItem('notiflyProjectId', prjId),
74
66
  AsyncStorage.setItem('notiflyUserName', userName),
75
67
  AsyncStorage.setItem('notiflyUserPassword', password),
76
68
  ])
77
-
78
- notifee.requestPermission()
79
- if (Platform.OS === 'android') {
80
- notifee.createChannel({
81
- id: "foreground",
82
- name: "foreground",
83
- importance: AndroidImportance.HIGH,
84
- })
85
- }
86
- notifee.onBackgroundEvent(async ({ type, detail }) => {
87
- const { notification } = detail;
88
- const campaign_id = notification.data.campaign_id;
89
- if (!campaign_id) {
90
- return
91
- }
92
- switch (type) {
93
- case 3:
94
- try {
95
- await logEvent("push_delivered", { "campaign_id": campaign_id, "status": "background-notifee" }, null, true);
96
- } catch (err) {
97
- console.warn('[Notifly]: ', err);
98
- }
99
- break;
100
- }
101
- });
102
69
  } catch (err) {
103
70
  console.warn("[Notifly]: ", err);
104
71
  }
105
72
  }
106
73
 
107
- exports.foregroundSetting = function () {
108
- messaging().onMessage(async remoteMessage => {
109
- await notifee.displayNotification({
110
- title: remoteMessage.notification.title,
111
- body: remoteMessage.notification.body,
112
- data: remoteMessage.data,
113
- android: {
114
- channelId: "foreground",
115
- },
116
- });
117
- await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "foreground" }, null, true);
118
- });
119
- notifee.onForegroundEvent(async ({ type, detail }) => {
120
- const { notification } = detail;
121
- const campaign_id = notification.data.campaign_id;
122
- if (!campaign_id) {
123
- return
124
- }
125
- if (type == 1) {
126
- try {
127
- if (notification.data.link) {
128
- Linking.openURL(notification.data.link)
129
- }
130
- await logEvent("push_click", { "campaign_id": campaign_id, "status": "foreground" }, null, true);
131
- } catch (err) {
132
- console.warn('[Notifly]: ', err);
133
- }
134
- }
135
- });
136
- }
137
-
138
74
  async function getCognitoIdToken(userName, password) {
139
75
  const myHeaders = new Headers();
140
76
  myHeaders.append("X-Amz-Target", "AWSCognitoIdentityProviderService.InitiateAuth");
@@ -304,4 +240,4 @@ async function _apiCall(apiUrl, requestOptions) {
304
240
  const result = fetch(apiUrl, requestOptions)
305
241
  .then(response => response.text());
306
242
  return result;
307
- }
243
+ }
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "notifly-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
9
  "peerDependencies": {
10
- "@notifee/react-native": "^7.3.0",
11
10
  "@react-native-async-storage/async-storage": "^1.17.11",
12
11
  "@react-native-firebase/app": "^16.4.3",
13
12
  "@react-native-firebase/messaging": "^16.4.3",