Follow

Add User Credentials

Add User Credentials

User credentials help you customize campaigns to your users. After you determine what type of user credentials your app uses, follow the steps below. Check Before You Begin for information about user credentials.

To add user credentials

  1. Bind the deviceready, pause and resume event listeners in your index.js file.

    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
        document.addEventListener('pause', this.onPaused, false);
        document.addEventListener('resume', this.onResume, false);
    }
  2. Incorporate the following lines in your onDeviceReady() callback function.

    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    // Substitute your Kahuna Secret Key and your Google SenderID (for Android) in the following line Kahuna.launchWithKey('KAHUNA_SECRET_KEY', 'SENDER_ID');

    // If you have a username, email address, or other
    // unique identifier for your user,
    // connect this session with their profile by providing those
    // credentials to Kahuna. Use only unique user identifiers, and
    // add only the credentials that you have actually obtained var credentials = KahunaUserCredentials();
    creds.addUserCredential(KahunaUserCredentials().EMAIL_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().USERNAME_KEY, username);
    creds.addUserCredential(KahunaUserCredentials().FACEBOOK_KEY, facebook_id);
    creds.addUserCredential(KahunaUserCredentials().TWITTER_KEY, twitter_id);
    creds.addUserCredential(KahunaUserCredentials().LINKEDIN_KEY, linkedin_id);
    creds.addUserCredential(KahunaUserCredentials().USER_ID_KEY, user_id);
    creds.addUserCredential(KahunaUserCredentials().INSTALL_TOKEN_KEY, installtoken);
    creds.addUserCredential(KahunaUserCredentials().GOOGLE_PLUS_ID_KEY, gplus_id);

    Kahuna.login(credentials);
    }
  3. Call Kahuna.onStop() and Kahuna.onStart() in the paused and resume callback functions as shown below.

    onPaused: function() {
        Kahuna.onStop();
    }
    
    onResume: function() {
        Kahuna.onStart();
    }
  1. Add the following code so that Kahuna knows when a user logs out of your app.

    Kahuna.logout();
  1. Add the following code to send Kahuna the credentials of users who log into your app or register for the first time, if it is not available during onDeviceReady.

     // If you have a username or an email address for your user,
    // connect this session with their profile by providing those
    // credentials to Kahuna. Use only unique user identifiers, and
    // add only the credentials that you have actually obtained var credentials = KahunaUserCredentials();
    creds.addUserCredential(KahunaUserCredentials().EMAIL_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().USERNAME_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().FACEBOOK_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().TWITTER_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().LINKEDIN_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().USER_ID_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().INSTALL_TOKEN_KEY, email_address);
    creds.addUserCredential(KahunaUserCredentials().GOOGLE_PLUS_ID_KEY, email_address);

    Kahuna.login(credentials);

You have successfully added user credentials. Now follow the steps in Set Up Push Notifications.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments