Skip to content

Commit

Permalink
fix(interface): optional small icon in webpush
Browse files Browse the repository at this point in the history
  • Loading branch information
worotyns committed Jun 13, 2023
1 parent 285d8ad commit 7246548
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/server/client/interfaces/contexts/webpush.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface WebPushContext extends ActionBehaviour, OurMobileExtensions {
actions?: WebPushAction[];
badge?: number;
body?: string;
smallIcon: string;
smallIcon?: string;
icon?: string;
image?: string;
title?: string;
Expand Down
49 changes: 49 additions & 0 deletions examples/sender/send_transactional.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { PpgCoreClient, ProviderCredential } from "../../dist/server/client";

async function run() {
const client = new PpgCoreClient({
endpoint: "https://ppg-core.master1.qappg.co/v1",
apiKey: "00147c96-f0e8-4b40-b57d-992fd6c9a5ce"
});

const providersCredentials: ProviderCredential[] = [
{
type: "vapid",
payload: {
publicKey: "BMLa3ig2yYnIv-TcpqiShHjy8mRjGFt2vPq-AHEx4ARGen-g8_GfF5ybpqVeXy_zdaEUxYEz1kF1IsLwyIHmP2w",
privateKey: "Jqtg7AUhz2Ht3X3S4TE02nE7vZfcKYlHvyAFs1pl7ns"
}
}
];

const httpWebhookConfig = {
url: "https://enunrfkzi9ji.x.pipedream.net",
headers: {
from_worker: "yes"
}
}

const bucket = await client.createBucket(providersCredentials, httpWebhookConfig);

const dataContext = await bucket.createContext({
title: "My first push",
body: "Hello world from example",
behaviour: "https://pushpushgo.com",
icon: "https://fastly.picsum.photos/id/803/200/300.jpg?hmac=v-3AsAcUOG4kCDsLMlWF9_3Xa2DTODGyKLggZNvReno",
smallIcon: "https://fastly.picsum.photos/id/803/200/300.jpg?hmac=v-3AsAcUOG4kCDsLMlWF9_3Xa2DTODGyKLggZNvReno"
});

const result = await dataContext.sendMessages([
bucket.createReceiver({
"type": "vapid",
"foreignId": "my_id",
"p256dh": "BIIwKdd5QUNCEfcB7a8HXHXWt2UHdCqAF8zwLp-RZVjgQSZZAiXS5jKVXPafCC0VtRnlrtABwnePZpAxML-iZWk",
"auth": "AGVMtdybGTNy9oV04FJiOQ",
"endpoint": "https://web.push.apple.com/QORAQ85NCsx1bRVjDhr-tWjJRpVBYc12zZbCtvPdgTFmqiG5DCGDOgN0JM_EpBOeqhAKEnEYn3468dQg5SoDUicnhOvoVQLmyC_etcPLo2BLILGeD4M3i83DsMbeDvxjq5ETj8OQSz9-im9hj3j56rmbe5sxRVdH15BOYIEB1sk",
"publicKey": "BMLa3ig2yYnIv-TcpqiShHjy8mRjGFt2vPq-AHEx4ARGen-g8_GfF5ybpqVeXy_zdaEUxYEz1kF1IsLwyIHmP2w" })
]);

console.log(JSON.stringify(result, null, 2));
}

run().catch(console.error);

0 comments on commit 7246548

Please sign in to comment.