Push notifications

Integrations & APIs / Push notifications
Integrations & APIs Push notifications

Push notifications

quanly | 04:24 PM 15/03/2018

Tanaza Push Contact Notifications allow customers to receive updates about events.
Each customer will be able to expose a public endpoint where the Tanaza Infrastructure will deliver notification messages (through HTTP Post Requests) within useful informations about the event.

Tanaza Push Contact Notifications allow customers to receive updates about events.

Each customer will be able to expose a public endpoint where the Tanaza Infrastructure will deliver notification messages (through HTTP Post Requests) within useful informations about the event.
 
Currently the available events are limited to: User Login.
 

IMPORTANT
the User Login push notification is able to send all details of a contact that uses the Tanaza Splash Page to access the Wi-Fi, including information related to Facebook Login and Social Actions (if available).



In order to activate Push Notifications , you should follow these steps:
 

STEP 1

In order to access to your Soical Dashboard go to cloud.tanaza.com  and click on Hotspots 


Dashboard

 

STEP 2

Go to your SSID List on upper right corner, choose the wanted SSID and click on Configure SSID:

User-added image


 

STEP 3

Select the Tab Push Notification ( left ) > turn on and configure your endpoint URL ( right ) and click Save at the end:

User-added image


 

Public Endpoint 

After configuring the feature from Tanaza dashboard as shown, you should now be aware of the new structure to be able to reconfigure your public endpoint in order to receive pushed data in a proper manner.

 

Login Push Object

Login object returned by the push notification and the export

Field Type Format Example Values
id
Exposed id of the database entry
string   55876328  
ap_id
Id of the Access Point to which the client connected
string  

1187456

 
SSID
Name of the SSID to which the client connected
string   Wi-fi Hotel Santa Domenica  
ip_address
Ip address of the client who connected to the SSID
string ipv4 195.22.30.56  
mac_address
MAC address of the client who connected to the SSID
string mac_address

AA:A0:C9:14:C8:29

 
auth_method
Authentication method used by the client
string facebook google, linkedin, facebook, twitter, instagram,
live, tanazaclick, tanaza-email, tanaza-phone,
tanaza-emailphone, tanazacode, vk,
tanaza-coupon, tanaza-sms, 
custom_form
 
roaming
Flag to identify a connection through roaming
boolean false    
created_at
Date and time when the client connected
string iso8601 2015-07- 31T10:23:26.216Z  
client
The client connected to the SSID
object client    
user_agent 
User-Agent of the device used by the client
string   Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr;
LG-L160L Build/IML74K) AppleWebkit/534.30
(KHTML, like Gecko) Version/4.0
Mobile Safari/534.30"
 
registered_at
Date and time when the client connected for the first time
string  iso8601

2015-07-31T10:23:26.216Z

 
last_login
Last time the client connected

string 

iso8601

2017-07-31T10:23:26.216Z

 

logins_count
Total count of client connections

number 

 

23

 



 

Client

The client connected to the SSID

Filed

Type

Format

Example

Values

id 
Exposed client id of the database entry
string   5757935  
first_name
First name of the connected client
string   Jon  
last_name 
Last name of the connected client
string   Snow  
picture
Image URL of the connected client
string url https://en.wikipedia.org/wiki/File:
Jon_Snow- Kit_Harington.jpg
 
gender
Gender of the connected client
string   male male, female
email
Email address of the connected client
string email jon.snow@stark.com  
phone
Phone number of the connected client
string   +44 393 7649204  
birthday
Date of birth of the person associated to the client
string iso8601 1978-02-30  
location
An object describing the location provided by the
object location    


 

Location

An object describing the location provided by the client

Field

Type

Format

Example

Values

name
The location name provided by the client
string   Milan, Area  
city
Name of the city extracted from the location
string   Milan  
country_code
code of the country extracted from the location
string   IT  
latitude
Latitude of the location
number   40.68906  
longitude
Latitude of the location
number   -74.044636  




Currently the system will not take care of the endpoint response.
If the endpoint fails to catch the request the notification will be lost. For this reason we highly recommend to test the system before the final release.

 

Code example in PHP for endpoint implementation


This snippet shows how to get the POST body correctly and how to debug what data is received.
 

<?php

/*
* Get the request POST body, encoded in json format, and decode it 
*/
$json = file_get_contents('php://input');
$logins=json_decode($json,true);
/**
* The $logins variable contains now an array of logins stored as associative array
*/
$logins_count=count($logins);
echo ("Received ".$logins_count." login notifications - ");
for($index=0;$index<$logins_count;$index++){
     $login=$logins[$index];
     echo "ID login:".$login["id"]." - ";
     echo (var_export($login,true))." - ";
}
?>




Example of the content received:
 

[{
  "id": "55876328",
  "ap_id": "Wi-fi Hotel Santa Monica",
  "SSID": "Wi-fi Hotel Santa Monica",
  "ip_address": "98.139.180.149",
  "mac_address": "00:A0:C9:14:C8:29",
  "auth_method": "facebook",
  "created_at": "2015-07-31T10:23:26.216Z",
  "user_agent": "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
  "client": {
    "id": "5757935",
    "first_name": "Jon",
    "last_name": "Snow",
    "picture": "https://en.wikipedia.org/wiki/File:Jon_Snow-Kit_Harington.jpg",
    "gender": "male",
    "email": "jon.snow@stark.com",
    "phone": "+44 393 7649204",
    "birthday": "02-10-1978",
    "location": {
      "name": "Milan Area",
      "city": "Milan",
      "country": "Italy",
      "country_code": "IT",
      "latitude": 40.68906,
      "longitude": -74.044636
    },
    "logins_count": 23,
    "terms_and_conditions": "{\"general\": true, \"marketing\": false}"
  }
}]
Từ khóa :