Skip to content

Repository files navigation

pushwoosh-capacitor-plugin

Pushwoosh plugin for Capacitor

Install

NPM Installation

npm install pushwoosh-capacitor-plugin@1.0.11
npx cap sync

Git Installation

npm install git+https://github.com/Pushwoosh/pushwoosh-capacitor-plugin.git#1.0.11
npx cap sync

Usage

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(...)

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() => Promise<{ value: string | null; }>

Returns: Promise<{ value: string | null; }>


getPushwooshHWID()

getPushwooshHWID() => Promise<{ value: string | null; }>

Returns: Promise<{ 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() => 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()

clearLaunchNotification() => void

setUserId(...)

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

About

Pushwoosh plugin for Capacitor

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages