SDK
PushPushGo SDK is a software development kit that allows you to integrate web push without our integration script, but with customization possibilities.
Setup
Place PushPushGo service worker with your project Id in sw.js file on the website server.
Copy SDK script and place it in the website source code. Integration script has to be placed in the section of website's DOM structure.
Initialize SDK client.
projectId
string
required
vapidPublicKey
string
required
isHTTPS
boolean
required, whetver your website address has http
or https
protocol
endpoint
string
required, value: https://api.pushpushgo.com
websitePushId
string
optional, for Safari < 16 integration
swPath
string
optional, path to sw.js
file when other than root
Push notifications
isPushSupport(): Promise<void>
isPushSupport(): Promise<void>
Check if the browser supports web push notifications.
checkPermission(): Promise<boolean>
checkPermission(): Promise<boolean>
Check for native permission.
Subscription
register(options?: ISubscribeOptions): Promise<string>
register(options?: ISubscribeOptions): Promise<string>
Register new subscriber - show popup dialog or native permission window
returns
subscriberId
fields
{ customId?: string}
optional
tags
string[]
optional
isSubscribed(): Promise<boolean>
isSubscribed(): Promise<boolean>
Check if subscriber is registered
getId(): Promise<string>
getId(): Promise<string>
returns
subscriberId
unsubscribe(): Promise<void>
unsubscribe(): Promise<void>
Unsubscribe existing subscriber at database
Custom Id
setCustomId(customId: string | number): Promise<void>
setCustomId(customId: string | number): Promise<void>
Sets customId in cloned store
getCustomId(): Promise<string>
getCustomId(): Promise<string>
returns
subscriber's customId
Labels
appendTags(tags: string[]): Promise<string[]>
appendTags(tags: string[]): Promise<string[]>
Append tags to store. For tag with labels support use labelName:tagName
syntax.
tags
string[]
getTags(): Promise<string[]>
getTags(): Promise<string[]>
returns
current subscriber's tags
removeTags(tags: string[]): Promise<string[]>
removeTags(tags: string[]): Promise<string[]>
Remove tag(s) by label from store For labels support please use 'labelName:tagName'
syntax
getTagsToRemove(): Promise<string[]>
getTagsToRemove(): Promise<string[]>
returns
subscriber's tags to remove
Session data
setSelector(selectorName: string, value: string | number | null | boolean): Promise<void>
setSelector(selectorName: string, value: string | number | null | boolean): Promise<void>
Set selector value - field must be declared in application first
clearState(): void
clearState(): void
Clear state, reset values
Beacons
send(immediately?: boolean): Promise<boolean>
send(immediately?: boolean): Promise<boolean>
Set beacon to send on event before unload
Last updated
Was this helpful?