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. In your application delegate, incorporate the following lines.

    If you use only username, email, or userID credentials for your users, add only these credentials. If you have additional user credentials you want to add for your users, such as Facebook ID or Twitter ID, add these credentials also. Credentials must be unique across all your users.

    #import <Kahuna/Kahuna.h>
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        [Kahuna launchWithKey:@"KAHUNA_SECRET_KEY"];
        // Login the user. You can skip this below section if your app is an anonymous app.
        KahunaUserCredentials *uc = [Kahuna createUserCredentials];
        [uc addCredential:KAHUNA_CREDENTIAL_USER_ID withValue:@"User's Id"];
        [uc addCredential:KAHUNA_CREDENTIAL_USERNAME withValue:@"User's Username"];    
        [uc addCredential:KAHUNA_CREDENTIAL_EMAIL withValue:@"User's email"];
        [uc addCredential:KAHUNA_CREDENTIAL_FACEBOOK withValue:@"User's Facebook id"];
        [uc addCredential:KAHUNA_CREDENTIAL_TWITTER withValue:@"User's Twitter id"];
        [uc addCredential:KAHUNA_CREDENTIAL_LINKEDIN withValue:@"User's LinkedIn id"];
        [uc addCredential:KAHUNA_CREDENTIAL_GOOGLE_PLUS withValue:@"User's Google Plus id"];
        [uc addCredential:KAHUNA_CREDENTIAL_INSTALL_TOKEN withValue:@"User's Install Token"];
        [uc addCredential:KAHUNA_CREDENTIAL_MOBILE_NUMBER withValue:@"User's mobile phone number"];
        NSError *error = nil;
        [Kahuna loginWithCredentials:uc error:&error];
        if (error) {NSLog(@"Login Error : %@", error.description);
        // Add your app initialization code here
        return YES;
  2. Add the following code to send Kahuna the credentials of users who log into your app or register for the first time.

    KahunaUserCredentials *uc = [Kahuna createUserCredentials];
    NSError *error = nil;
    [Kahuna loginWithCredentials:uc error:&error];
    if (error) {
        NSLog(@"Login Error : %@", error.description);
  3. Add the following code so that Kahuna knows when a user logs out of your app.

    [Kahuna logout];

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