">

Pushing Events to the Screen

The Enplug platform allows any app to receive real time notifications from an external service.

  1. Use your app’s configuration page (loaded each time when the customer first enables your app) to make an association of Enplug venueId with an account in your system if needed.

  2. On your server use the following endpoint to push notifications: 

    https://adservernet.enplug.com/v1/notifications/post?token={yourAppToken}

    You can see your auth token on the apps configuration page in the developer section of the dashboard. The payload or this POST request is:

    {  
        VenueId: "venueid",        // Id of the location the update is for
        TriggerApp: true/false,    // If set to true and app is offscreen, we
                                   // will try to show app
        Data: "json"               // JSON payload to be passed to your app
    }
  3. In your app’s player page use Events API to make the screen respond appropriately. Your listener will receive the JSON data from each event you push.

    enplug.on( 'myEventName', function( eventData ) {
      // process the event
    });

    In Social apps, an app listens for a "social" event and immediately handles it. In the callback function, it receives an object with an action (string ) and item (object) property.

    enplug.on( 'social', function( data ) {
      // handle event data
    });
    
    {
       action:("new"|"delete"|"update"),
       item:item
    }
    
    
  4. Using the Application Status API, You can also request the reason why an app is being rendered on-screen by calling enplug.appStatus.getTrigger().  The response will contain a reason and data property.

    In Social Apps, this method can be called as soon as you need the data from a social network, typically before calling enplug.appStatus.start() while it's still loading.

    {
      reason:("schedule"|"event"),
      data: {
        Id, 
        SocialNetwork,
        SocialItemId,
        FeedId,
        CreatedTime,
        LastSavedTime,
        CreatedTime,
        ProfanityCount,
        ProfaneWords,
        IsApproved,
        IsAllowed,
        SecondaryText,
        ImageLocalPath,
        UserImageLocalPath
        }
    }