Others Methods

Some others important methods.

Get FCM/APNS Token

This function provides an FCM subscription token (in case of Android)and APNS token (in case of IOS).

NotifyVisitors.getRegistrationToken(callback_function);

//Example :-
NotifyVisitors.getRegistrationToken(function(callback){
     alert("response : " + callback); 
 });

Subscribe Push Category

In case you want to create a different category for sending push notifications or you want to unsubscribe users for all categories.

NotifyVisitors.subscribePushCategory(JSONArray categoryInfo, boolean unSubscribe2All);

//Example
Var categoryInfo = ["sales", "service" ];
NotifyVisitors.subscribePushCategory(categoryInfo, false);

NotifyVisitors UID

NV UID stands for NotifyVisitors Unique Identifier. We create this ID at our backend side & allot one unique id to every user whether it’s known or anonymous. This ID can be seen in the NV dashboard >> Mobile Push >> Subscribers section.

If any user wants this UID in their app for any use according to their use-case then they can implement this function & it will provide you the UID as String.

NotifyVisitors.getNvUID(callback);

//ExampleNotifyVisitors.getNvUID(function(callback){
     alert("response : " + callback); 
 });

Send Push Payload to NotifyVisitors Plugin (Android only)

This will be used when your app has your Firebase cloud messaging implementation. Then use these functions to pass the push payload to NotifyVisitors SDK.

NotifyVisitors.isPayloadFromNvPlatform(message (as JSONString), function(callback:any) {
   if(callback == "true") {
       NotifyVisitors.getNV_FCMPayload(message (as JSONString)  );
   }
});

For example,

firebaseMessaging.onMessage().subscribe((message) => {
        NotifyVisitors.isPayloadFromNvPlatform(JSON.stringify(message), function(callback:any) {
            if(callback == "true") {
               NotifyVisitors.getNV_FCMPayload(JSON.stringify(message));
            }
        });  
});
 
firebaseMessaging.onBackgroundMessage().subscribe((message) => {
        NotifyVisitors.isPayloadFromNvPlatform(JSON.stringify(message), function(callback:any) {
            if(callback == "true") {
               NotifyVisitors.getNV_FCMPayload(JSON.stringify(message));
            }
        }); 
});