Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guideDeveloper guideAdmin guide
Company siteHelp center
English
  • Русский
  • English
v74
  • v74
  • v73
  • v72
Login
  • User documentation
  • FAQ
  • Altcraft glossary
  • Profiles and databases
  • Communication channels
    • Email channel
    • Push channel
      • Mobile Push
      • Web push
        • Preliminary Settings
        • Web browser push configuration
        • Connecting Web Push to a Website
        • Transferring Data to the Platform
        • Web Push SDK Methods
        • Import of subscriptions from third-party push services
    • SMS channel
    • Creating mailing from scratch
    • Communication Channels Workflow
    • Руководство: SMS-рассылка через УТШ
    • Руководство: push-рассылка через сервис от "Согласие"
  • Segmentation
  • Message templates
  • Mailings
  • Campaigns
  • Automation scenarios
  • Market
  • Loyalty programs
  • Reports and analytics
  • Integrations
  • Weblayers
  • Settings
  • API requests: where to start
  • Changelog
  • library
  • Communication channels
  • Push channel
  • Web push
  • Web Push SDK Methods
Documentation for version v74

Web Push SDK Methods

tip

For more details on setting up Web Push mailings on the platform and installing the SDK on your website, refer to this section.

This article describes the Web Push SDK methods and their possible parameters. Each method is also accompanied by a usage example.

initSubscription​

This method initializes a subscription. It is used to record client data in a profile and perform a search among existing profiles.

Parameters​

ParameterTypeRequiredDescription
matchobjectYesDefines profile matching. If no profile database is provided for the search, the platform will search within the databases linked to the resource.
updateobjectNoContains data to be added to a new or existing profile.

Usage Example​

const akPush = new AKPush();
akPush.initSubscription(
{
db: 1
email: 'example@email.com'
}, // Searching for a profile by email. If no match is found, it will be recorded in the profile.

{
_fname: 'Anatoly',
_lname: 'Wasserman'
} // Recording the subscriber's first and last name in the profile
)

updateSubscription​

This method updates profile data and modifies the status of push subscriptions.

Parameters​

ParameterTypeRequiredDescription
matchobjectYesDefines profile matching. If no profile database is provided for the search, the platform will search within the databases linked to the resource.
updateobjectNoContains data to be added to a new or existing profile. If you want to pass the inexclusive parameter without updating the profile data, you must specify an empty {} object in update.
inexclusivebooleanNoIf the inexclusive flag is not provided or set to false:

1. If no database filter is specified, each database of the resource will have only one profile with one subscription for the current token with the status "Subscribed".
2. If a filter is specified, each specified database will have only one profile with one subscription for the current token with the "Subscribed" status. In other databases, all matching subscriptions to the resource for all profiles will be suspended.

If the inexclusive flag is set to true, the call is equivalent to AKPush.initSubscription, meaning the profile data will be updated and the subscription status changed to "Subscribed".

Usage Example​

const akPush = new AKPush();
akPush.updateSubscription(
{
db: [15,20]
email: 'example@email.com'
},

{
_fname: 'Anatoly',
_lname: 'Wasserman'
}, // Recording the subscriber's first and last name in the profile
false // Whether to suspend all subscriptions to the resource with the current browser token for other profiles (default)
)

AKPush.events.on​

This method subscribes to events related to push notifications.

Parameters​

ParameterTypeRequiredDescription
subscribe
update_subscription
suspend_subscription
stringYesName of the triggered event.
callbackfunctionYes

Function that will be called when the event occurs. For subscribe, the returned parameters will be:

{
browser: "<subscriber's browser>"​
provider: "<push provider>"​
token: "<subscriber's token>"
}


For update_subscription and suspend_subscription, the returned parameters will be:

{
browser: "<subscriber's browser>"​
provider: "<push provider>"​
token: "<subscriber's token>"
tokenCached: "<cached subscriber's token>"
}

Usage Example​

AKPush.events.on('subscribe', (data) => { // Subscribe to the subscribe event
console.log(data);
});
AKPush.events.on('update_subscription', (data) => { // Subscribe to the update_subscription event
console.log(data);
});

suspendSubscription​

This method suspends a user's push notification subscription. The subscription can be resumed using the same method.

Parameters​

ParameterTypeRequiredDescription
matchobjectYesDefines profile matching. If no profile database is provided for the search, the platform will search within the databases linked to the resource.
updateobjectNoContains data to be added to a new or existing profile.

Usage Example​

AKPush.suspendSubscription(
{
db: 1
email: 'example@email.com'
},
{
_status: 'inactive'
} // Updating the subscriber's profile status
)

AKPush.removeToken​

This method removes a device token from the cache. It is used, for example, when a user changes on the device. No parameters are required for this method.

Usage Example​

AKPush.removeToken()
Last updated on Feb 6, 2025
Previous
Transferring Data to the Platform
Next
Import of subscriptions from third-party push services
  • initSubscription
    • Parameters
    • Usage Example
  • updateSubscription
    • Parameters
    • Usage Example
  • AKPush.events.on
    • Parameters
    • Usage Example
  • suspendSubscription
    • Parameters
    • Usage Example
  • AKPush.removeToken
    • Usage Example
© 2015 - 2025 Altcraft, LLC. All rights reserved.