Skip to content

Commit 7d2fd17

Browse files
author
Heart
committed
build: 0.1.17
1 parent 790ff66 commit 7d2fd17

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pam-react-native",
3-
"version": "0.1.16",
3+
"version": "0.1.17",
44
"description": "Pam SDK for React Native",
55
"source": "./src/index.tsx",
66
"main": "./lib/commonjs/index.js",

src/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@ export class PamAPI {
166166
return result;
167167
}
168168

169+
async loadPushNotifications(
170+
database: string,
171+
contactID: string
172+
): Promise<PamPushMessage[] | null> {
173+
let response: any;
174+
try {
175+
const url = `/api/app-notifications?_database=${database}&_contact_id=${contactID}`;
176+
response = await this.http.get(url, {});
177+
} catch (e) {}
178+
if (response) {
179+
return PamPushMessage.parseFromResponse(response.items);
180+
}
181+
return null;
182+
}
183+
169184
async loadPushNotificationsFromCustomerID(
170185
database: string,
171186
contactID: string,

src/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ export class Pam {
177177
return undefined;
178178
}
179179

180+
static async loadPushNotifications(): Promise<PamPushMessage[] | null> {
181+
const contactID = Pam.shared?.contactState?.getContactId();
182+
const database = Pam.shared?.contactState?.getDatabase();
183+
if (!contactID || !database) {
184+
return null;
185+
}
186+
return await Pam.pamApi.loadPushNotifications(database, contactID);
187+
}
188+
180189
static async loadPushNotificationsFromCustomerID(
181190
customerID: string
182191
): Promise<PamPushMessage[] | null> {

0 commit comments

Comments
 (0)