pushwoosh-capacitor-plugin
v1.0.8
Published
Pushwoosh plugin for Capacitor
Readme
pushwoosh-capacitor-plugin
Pushwoosh plugin for Capacitor
Install
NPM Installation
npm install [email protected]
npx cap syncGit Installation
npm install git+https://github.com/Pushwoosh/pushwoosh-capacitor-plugin.git#1.0.8
npx cap syncUsage
Initialization
import { 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);User ID and Events
Pushwoosh.setUserId('user_123');
Pushwoosh.postEvent('purchase', {
product: 'Premium Plan',
price: '9.99',
});Tags
// Set tags
await Pushwoosh.setTags({
age: 25,
name: 'John',
favorite_categories: ['sports', 'news'],
});
// Get tags
const { tags } = await Pushwoosh.getTags();
console.log('Tags:', tags);API
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(...)
onDeviceReady(config: PushwooshConfig) => void| Param | Type |
| ------------ | ----------------------------------------------------------- |
| config | PushwooshConfig |
registerDevice()
registerDevice() => Promise<{ pushToken: string; }>Returns: Promise<{ pushToken: string; }>
unregisterDevice()
unregisterDevice() => Promise<void>additionalAuthorizationOptions(...)
additionalAuthorizationOptions(options: AuthOptions) => void| Param | Type |
| ------------- | --------------------------------------------------- |
| options | AuthOptions |
setTags(...)
setTags(config: PushwooshTags) => Promise<void>| Param | Type |
| ------------ | ------------------------------------------------------- |
| config | PushwooshTags |
getTags()
getTags() => Promise<{ tags: PushwooshTags; }>Returns: Promise<{ tags: PushwooshTags; }>
getPushToken()
getPushToken() => { value: string | null; }Returns: { value: string | null; }
getPushwooshHWID()
getPushwooshHWID() => { value: string | null; }Returns: { value: string | null; }
getRemoteNotificationStatus()
getRemoteNotificationStatus() => Promise<{ status: RemoteNotificationStatus; }>Returns: Promise<{ status: RemoteNotificationStatus; }>
setApplicationIconBadgeNumber(...)
setApplicationIconBadgeNumber(badge: number) => void| Param | Type |
| ----------- | ------------------- |
| badge | number |
getApplicationIconBadgeNumber()
getApplicationIconBadgeNumber() => Promise<{ badge: number; }>Returns: Promise<{ badge: number; }>
addToApplicationIconBadgeNumber(...)
addToApplicationIconBadgeNumber(badge: number) => void| Param | Type |
| ----------- | ------------------- |
| badge | number |
getLaunchNotification()
getLaunchNotification() => { notification: string; }Returns: { notification: string; }
clearLaunchNotification()
clearLaunchNotification() => voidsetUserId(...)
setUserId(userId: string) => void| Param | Type |
| ------------ | ------------------- |
| userId | string |
setLanguage(...)
setLanguage(language: string) => void| Param | Type |
| -------------- | ------------------- |
| language | string |
setApiToken(...)
setApiToken(token: string) => void| Param | Type |
| ----------- | ------------------- |
| token | string |
postEvent(...)
postEvent(event: string, attributes?: Record<string, string> | undefined) => void| Param | Type |
| ---------------- | --------------------------------------------------------------- |
| event | string |
| attributes | Record<string, string> |
setMultiNotificationMode()
setMultiNotificationMode() => Promise<void>setSingleNotificationMode()
setSingleNotificationMode() => Promise<void>pushReceivedCallback(...)
pushReceivedCallback(callback: PushwooshNotificationCallback) => Promise<CallbackID>| Param | Type |
| -------------- | --------------------------------------------------------------------------------------- |
| callback | PushwooshNotificationCallback |
Returns: Promise<string>
pushOpenedCallback(...)
pushOpenedCallback(callback: PushwooshNotificationCallback) => Promise<CallbackID>| Param | Type |
| -------------- | --------------------------------------------------------------------------------------- |
| callback | PushwooshNotificationCallback |
Returns: Promise<string>
presentInboxUI(...)
presentInboxUI(params?: Record<string, any> | undefined) => void| Param | Type |
| ------------ | ------------------------------------------------------------ |
| params | Record<string, any> |
setCommunicationEnabled(...)
setCommunicationEnabled(enabled: boolean) => Promise<{ result: void | string; }>| Param | Type |
| ------------- | -------------------- |
| enabled | boolean |
Returns: Promise<{ result: string | void; }>
isCommunicationEnabled(...)
isCommunicationEnabled(success: (enabled: boolean) => void) => void| Param | Type |
| ------------- | ------------------------------------------ |
| success | (enabled: boolean) => void |
Interfaces
PushwooshConfig
| Prop | Type |
| ----------------- | ------------------- |
| appid | string |
| serviceName | string |
PushwooshTags
Type Aliases
AuthOptions
Record<string, number|string>
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
RemoteNotificationStatus
Record<string,string|number|boolean>
PushwooshNotificationCallback
(message: string | null, err?: any): void
CallbackID
string
