OneSignal

Skip to end of metadata
Go to start of metadata

Overview

OneSignal is a high volume and reliable push notification service for websites and mobile applications. It support all major native and mobile platforms by providing dedicated SDKs for each platform, a RESTful server API, and an online dashboard for marketers to design and send push notifications. OneSignal features include segmentation, automatic/triggered notifications, variable substitution, a notification delivery API, and detailed reporting tools.  

Push notifications are a new marketing channel to engage your site visitors without knowing their email or other contact details, a channel built into every mobile device sold today. They allow apps to reach out to users with short messages that users may respond to. Web push notifications are messages that come from a website. You get them on your desktop or device even when the website is not open in your browser. Web Push Notifications generally work only on SSL sites (HTTPS), but OneSignal provides this feature for also for HTTP sites by assigning you a free HTTPS subdomain.

Implementation

The following image illustrates the flow when integrating Gigya and OneSignal:


  1. User registers / logs in via Gigya
  2. Gigya checks for this user in OneSignal
  3. If the user is registered in OneSignal, Gigya sends tags to OneSignal, based on their profile data
  4. In OneSignal, the user is assigned to one or more segments, according to the tags passed
  5. Based on the segmentation, personalized notifications can be sent

Prerequisites

  • You have registered to OneSignal.
  • You have set up a OneSignal app.
  • You have created the relevant segments in OneSignal (in this example, gender).

1. Integrate SDKs into your App

  1. Download Gigya's mobile SDK and follow the relevant documentation to integrate the SDK into your mobile application.
  2. Integrate OneSignal's mobile SDK and follow the documentation to integrate the SDK into your mobile application. 

2. Add Code

  1. Place the following code in the <head> tag of your site's index.html file: 

    <!-- Link to OneSignal -->
    <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async='async'></script>
    <script>
    	var OneSignal = window.OneSignal || [];
    	OneSignal.push(["init", {
    		appId: "0749ab6c-YOUR_APP_ID",
    		autoRegister: false,
    		httpPermissionRequest: {
    			enable: true
    		},
    		notifyButton: {
    			enable: false /* Set to false to hide */
    	            }
    	}]);
    </script>

    You can find your App ID in OneSignal App Settings:

     

  2. Add the following code to Gigya's onLogin event:

      function onLoginHandler(response) {            
                // Get User values
                var userEmail = response.profile.email;
                var userFirstname = response.profile.firstName;
                var userGender = response.profile.gender;
                // OneSignal API
                OneSignal.push(function () {
                    // Check if user already registered in OneSignal
                    OneSignal.isPushNotificationsEnabled(function (isEnabled) {                
                        // User already registered
                        if (isEnabled) {
                            // Get tags from OneSignal
                            OneSignal.getTags(function (tags) {
                                // Tags are there
                                if (tags) {
                                    // Check email tag and add/update it if not created or different
                                    if (!tags["email"] || tags["email"] != userEmail)
                                        OneSignal.sendTag("email", userEmail);
                                    // Check gender tag and add/update it if not created or different
                                    if (!tags["gender"] || tags["gender"] != userGender)
                                        OneSignal.sendTag("gender", userGender);
                                    // Check firstname tag and add/update it if not created or different
                                    if (!tags["firstname"] || tags["firstname"] != userFirstname)
                                        OneSignal.sendTag("firstname", userFirstname);
                                // No tags
                                else {
                                    // Send tags to OneSignal
                                    OneSignal.sendTags({
                                        email: userEmail,
                                        gender: userGender,
                                        firstname: userFirstname
                                    });
                                }                           
                            });
                        }
                    });
                });
          }

    See detailed explanation in the image below: 

As a result, attributes associated to the user's profile in Gigya, are pushed as tags to OneSignal: 





  • No labels