LogoLogo
Sign inSign up
  • PushPushGo Documentation
  • Web push
    • Overview
    • Instructions
      • Subscription tests
    • Service worker
    • Integration script
      • Subscription form
        • Subscription form creator
          • Topics
        • Subscription form delay
        • Display form rules
        • Confirmation window
      • Bell widget
        • Inbox
        • Topics
      • Google Analytics & Google Tag Manager
      • Default notification
      • Beacons
    • SDK
      • Examples
    • JS Code
    • Safari support
    • FAQ
  • Mobile push
    • Overview
    • Google Android
    • Apple iOS
    • Huawei Android
  • ONSITE NOTIFICATIONS
    • Overview
  • Onsite notifications
    • Create onsite notification
    • Edit onsite notification
    • Onsite notification report
    • Inbox
  • Onsite notifications list
  • Subscribers
    • Subscribers
      • Activity status
      • Subscriber Details
    • Labels
      • System Labels
      • Add Labels Manually
    • Segments
      • Create Segment
      • Copy Segment
      • Update Segment
      • Delete Segment
    • Geolocation
  • Campaigns
    • Campaigns
    • Push campaign
      • Create Campaign
        • Content
        • Audience
          • By Segment
          • By Labels
        • Provider options
        • Time
        • Drafts
      • Campaign List
        • Cancel Campaign
        • Copy Campaign
        • Copying and pasting campaigns between projects
        • Delete Campaign
      • Campaign Report
    • AB test
      • Create AB test
        • Variants
        • Audience
        • Provider options
        • Time
        • Save draft or accept a test
      • AB test list
      • Winner selection
      • AB test report
      • Cancel AB Test
      • Send AB test saved as draft
      • Resend AB test
      • Delete AB test
    • RSS campaign
      • Create RSS campaign
      • Audience
      • Enable RSS campaign
      • RSS campaign report
    • Chrome plugin for Rocket push
    • Multi Push
    • Daily push capping
    • Planner
    • FAQ
  • Automation
    • Overview
    • Automation
      • Create automation
        • Name
        • Flow
        • Renew flow
        • Start date
        • End date
        • Building the flow
        • Step
          • Trigger
          • Campaign
            • Create campaign
            • Edit campaign
            • Campaign templates
      • Edit automation
        • Update automation
      • Report
        • Automation report
        • Campaign report
    • Automation list
      • Prority
      • Action
      • Status
      • Reset flow time
  • Analytics
    • Project analytics
      • Subscribers
      • Campaigns
      • Automation
    • Organization analytics
      • Organization dashboard
        • Subscribers
        • Campaigns
        • Automation
      • Project comparison
    • Exports
  • Integrations
    • Webhooks
    • REST API Reference
  • Release notes
Powered by GitBook
On this page
  • Setup
  • Push notifications
  • Subscription
  • Custom Id
  • Labels
  • Session data
  • Beacons

Was this helpful?

  1. Web push

SDK

PushPushGo SDK is a software development kit that allows you to integrate web push without our integration script, but with customization possibilities.

Setup

  1. Place PushPushGo service worker with your project Id in sw.js file on the website server.

sw.js
importScripts('https://cdn.pushpushgo.com/$projectId/worker.js');
  1. 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.

index.html
<head>
    <script src="https://cdn.pushpushgo.com/scripts/sdk.js"></script>
</head>
  1. Initialize SDK client.

const config = {
  projectId: $projectId,
  vapidPublicKey: $vapidPublicKey,
  isHTTPS: $isHTTPS,
  endpoint: 'https://api.pushpushgo.com',
  swPath?: $serviceWorkerPath,
  websitePushId?: $websitePushId,
};

const client = new ppg.sdk.Client(config);
parameter
type
description

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>

Check if the browser supports web push notifications.

checkPermission(): Promise<boolean>

Check for native permission.

Subscription

register(options?: ISubscribeOptions): Promise<string>

Register new subscriber - show popup dialog or native permission window

returns subscriberId

parameter
type
description

fields

{ customId?: string}

optional

tags

string[]

optional

isSubscribed(): Promise<boolean>

Check if subscriber is registered

getId(): Promise<string>

returns subscriberId

unsubscribe(): Promise<void>

Unsubscribe existing subscriber at database

Custom Id

setCustomId(customId: string | number): Promise<void>

Sets customId in cloned store

getCustomId(): Promise<string>

returns subscriber's customId

Labels

appendTags(tags: string[]): Promise<string[]>

Append tags to store. For tag with labels support use labelName:tagName syntax.

parameter
type
description

tags

string[]

getTags(): Promise<string[]>

returns current subscriber's tags

removeTags(tags: string[]): Promise<string[]>

Remove tag(s) by label from store For labels support please use 'labelName:tagName' syntax

getTagsToRemove(): Promise<string[]>

returns subscriber's tags to remove

Session data

setSelector(selectorName: string, value: string | number | null | boolean): Promise<void>

Set selector value - field must be declared in application first

clearState(): void

Clear state, reset values

Beacons

send(immediately?: boolean): Promise<boolean>

Set beacon to send on event before unload

Last updated 3 months ago

Was this helpful?