Pushwoosh plugin for Capacitor
npm install pushwoosh-capacitor-plugin@1.0.11
npx cap syncnpm install git+https://github.com/Pushwoosh/pushwoosh-capacitor-plugin.git#1.0.11
npx cap syncimport { Pushwoosh } from 'pushwoosh-capacitor-plugin';
// 1. Register notification callbacks before initialization
Pushwoosh.pushReceivedCallback((notification, error) => {
if (error) {
console.error('Push receive error:', error);
return;
}
console.log('Push received:', JSON.stringify(notification));
});
Pushwoosh.pushOpenedCallback((notification, error) => {
if (error) {
console.error('Push open error:', error);
return;
}
console.log('Push opened:', JSON.stringify(notification));
});
// 2. Initialize Pushwoosh
Pushwoosh.onDeviceReady({
appid: 'XXXXX-XXXXX', // Pushwoosh Application ID
});
// 3. Register the device to receive push notifications
const { pushToken } = await Pushwoosh.registerDevice();
console.log('Registered with token:', pushToken);Pushwoosh.setUserId('user_123');
Pushwoosh.postEvent('purchase', {
product: 'Premium Plan',
price: '9.99',
});// Set tags
await Pushwoosh.setTags({
age: 25,
name: 'John',
favorite_categories: ['sports', 'news'],
});
// Get tags
const { tags } = await Pushwoosh.getTags();
console.log('Tags:', tags);onDeviceReady(...)registerDevice()unregisterDevice()additionalAuthorizationOptions(...)setTags(...)getTags()getPushToken()getPushwooshHWID()getRemoteNotificationStatus()setApplicationIconBadgeNumber(...)getApplicationIconBadgeNumber()addToApplicationIconBadgeNumber(...)getLaunchNotification()clearLaunchNotification()setUserId(...)setLanguage(...)setApiToken(...)postEvent(...)setMultiNotificationMode()setSingleNotificationMode()pushReceivedCallback(...)pushOpenedCallback(...)presentInboxUI(...)setCommunicationEnabled(...)isCommunicationEnabled(...)- Interfaces
- Type Aliases
onDeviceReady(config: PushwooshConfig) => void| Param | Type |
|---|---|
config |
PushwooshConfig |
registerDevice() => Promise<{ pushToken: string; }>Returns: Promise<{ pushToken: string; }>
unregisterDevice() => Promise<void>additionalAuthorizationOptions(options: AuthOptions) => void| Param | Type |
|---|---|
options |
AuthOptions |
setTags(config: PushwooshTags) => Promise<void>| Param | Type |
|---|---|
config |
PushwooshTags |
getTags() => Promise<{ tags: PushwooshTags; }>Returns: Promise<{ tags: PushwooshTags; }>
getPushToken() => Promise<{ value: string | null; }>Returns: Promise<{ value: string | null; }>
getPushwooshHWID() => Promise<{ value: string | null; }>Returns: Promise<{ value: string | null; }>
getRemoteNotificationStatus() => Promise<{ status: RemoteNotificationStatus; }>Returns: Promise<{ status: RemoteNotificationStatus; }>
setApplicationIconBadgeNumber(badge: number) => void| Param | Type |
|---|---|
badge |
number |
getApplicationIconBadgeNumber() => Promise<{ badge: number; }>Returns: Promise<{ badge: number; }>
addToApplicationIconBadgeNumber(badge: number) => void| Param | Type |
|---|---|
badge |
number |
getLaunchNotification() => Promise<{ notification: string; }>Android resolves the launch notification as a JSON string under value, and resolves nothing
when the app was not opened from a push, so the promise settles as undefined. iOS resolves
the raw notification dictionary under notification, or null in that same case. The declared
shape below matches neither platform; the payload mismatch is tracked separately.
Returns: Promise<{ notification: string; }>
clearLaunchNotification() => voidsetUserId(userId: string) => void| Param | Type |
|---|---|
userId |
string |
setLanguage(language: string) => void| Param | Type |
|---|---|
language |
string |
setApiToken(token: string) => void| Param | Type |
|---|---|
token |
string |
postEvent(event: string, attributes?: Record<string, string> | undefined) => void| Param | Type |
|---|---|
event |
string |
attributes |
Record<string, string> |
setMultiNotificationMode() => Promise<void>setSingleNotificationMode() => Promise<void>pushReceivedCallback(callback: PushwooshNotificationCallback) => Promise<CallbackID>| Param | Type |
|---|---|
callback |
PushwooshNotificationCallback |
Returns: Promise<string>
pushOpenedCallback(callback: PushwooshNotificationCallback) => Promise<CallbackID>| Param | Type |
|---|---|
callback |
PushwooshNotificationCallback |
Returns: Promise<string>
presentInboxUI(params?: Record<string, any> | undefined) => void| Param | Type |
|---|---|
params |
Record<string, any> |
setCommunicationEnabled(enabled: boolean) => Promise<{ result: void | string; }>| Param | Type |
|---|---|
enabled |
boolean |
Returns: Promise<{ result: string | void; }>
isCommunicationEnabled(success: (enabled: boolean) => void) => void| Param | Type |
|---|---|
success |
(enabled: boolean) => void |
| Prop | Type |
|---|---|
appid |
string |
serviceName |
string |
Record<string, number|string>
Construct a type with a set of properties K of type T
{
[P in K]: T;
}
Record<string,string|number|boolean>
(message: string | null, err?: any): void
string