Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Initialization

Using FireBase

Method Objective

The method allows using only Firebase to work with notifications for all platforms.

Warning

This method is a setter and should be used before the `.initPush()` initialization method described below.

Syntax and parameters

Code Block
themeFadeToGrey
pcsdk.firebase_only(param);


NameTypeRequirementDescription
parambooleanrequiredUse true value to make the SDK for all platforms work only with Firebase. The false value (default) will allow to use APNs (Apple Push Notification) and other providers directly bypassing Firebase.

Example of use

Code Block
languagejs
themeFadeToGrey
// Simple init 
pcsdk.initPush();

//onClick listener
pcsdk.initPush(onClickCallback);

// onReceivetive listener
pcsdk.initPush(false, onReceiveCallback);

// you can use different callback for notification, when app is in background.    
pcsdk.initPush(false, onReceiveCallback, onBackgroundReceiveCallback);
// If onBackgroundReceiveCallback not specified, used onReceiveCallback listener. 

// onClickCallback params
{
  "bigPictureUrl": "MESSAGE_IMAGE",
  "channelId": "personaclick-push", 
  "data": {
    "id": "MESSAGE_ID",
    "type": "MESSAGE_TYPE"
  }, 
  "foreground": true, 
  "id": "MESSAGE_ID", 
  "largeIconUrl": "MESSAGE_ICON",
  "message": "MESSAGE_BODY", 
  "title": "MESSAGE_TITLE", 
  "userInteraction": true
}
// onReceiveCallBack, onBackgroundReceiveCallback params
{
  "data": {
    "action_urls": "[]", 
    "actions": "[]",
    "body": "MESSAGE_BODY",
    "icon": "MESSAGE_ICON", 
    "id": "MESSAGE_ID",
    "image": "MESSAGE_IMAGE", 
    "title": "MESSAGE_TITLE", 
    "type": "MESSAGE_TYPE"
  }, 
  "from": "MESSAGE_FROM", 
  "messageId": "FMC_MESSAGE_ID", 
  "sentTime": TIMESTAMP, 
  "ttl": TTL_VALUE
}

Token Send

Code Block
languagejs
themeFadeToGrey
pcsdk.setPushTokenNotification('NEW_TOKEN');

Actions Tracking

Code Block
languagejs
themeFadeToGrey
const params = {
  code: 'CODE',
  type: 'TYPE'
};
// Track user click notification
pcsdk.notificationClicked(params);

// Track Notification received
pcsdk.notificationReceived(params);
Table of ContentsmaxLevel2classpersonaclick-fixed-position
pcsdk.firebase_only(true);


Asking For Token

Method Objective

The method allows managing the token request for push notifications.

Warning

This method is a setter and should be used before the `.initPush()` initialization method described below.

Syntax and parameters

Code Block
themeFadeToGrey
pcsdk.askPushPermissions(param);


NameTypeRequirementDescription
parambooleanoptionallyThe true value (the default) allows the token to be requested, and false disallows it.

Example of use

Code Block
languagejs
themeFadeToGrey
pcsdk.askPushPermissions(false);



Initialization

Method Objective

The method allows sending click tracking to the system, displaying a simple notification by the SDK, and sending the data necessary to track and display the notification to the user's methods via a callback.

Syntax and parameters

Code Block
themeFadeToGrey
pcsdk.initPush(click, receive, background_receive);

NameTypeRequirementDescription
clickfunction/booleanoptionallyCustom function to send a notification click event. If not used or has the false value, SDK will send click tracking by itself.
receivefunction/booleanoptionallyCustom function to show the notification. If not used or has the false value, SDK will show basic notification by itself.
background_receivefunctionoptionallyCustom function to show a notification in the background. If not used, the SDK will show a basic notification by itself.

Data for Callback Functions

Callback NameData Format
click


The Payloads structures are available under Push Payloads (Mobile SDKs).

receive
background_receive

Examples of use

Code Block
languagejs
themeFadeToGrey
// Click tracking and showing the simple notification by the SDK
pcsdk.initPush();

// Custom method for click tracking, but showing simple notification by the SDK
pcsdk.initPush(onClickCallback);

// Click tracking and showing simple notification by the SDK, but showing notification by custom method for background mode
pcsdk.initPush(false, false, onBackgroundReceiveCallback);

// Click tracking by the SDK, but showing notifications including in the background by custom methods
pcsdk.initPush(false, onReceiveCallback, onBackgroundReceiveCallback);

// Click tracking and showing notifications including in the background by custom methods
pcsdk.initPush(onClickCallback, onReceiveCallback, onBackgroundReceiveCallback);



Column

Page Navigation

Table of Contents
maxLevel1
indent0px
stylenone




Related Pages

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
cqllabel in ( "notifications" , "apppush" )