Profiles / Profile attributes |
Use the following example code to interact with Profiles attributes.
// to set a profile attribute: Localytics.setProfileAttribute("Age", 45, Localytics.ProfileScope.ORGANIZATION); Localytics.setProfileAttribute("Lucky numbers", new long[]{8, 13}, Localytics.ProfileScope.APPLICATION); Localytics.setProfileAttribute("Birthday", new GregorianCalendar(1962, 11, 23).getTime(), Localytics.ProfileScope.ORGANIZATION); Localytics.setProfileAttribute("Upcoming sales calls", new Date[]{new GregorianCalendar(2015, 10, 1).getTime(), new GregorianCalendar(2016, 3, 17).getTime()}, Localytics.ProfileScope.APPLICATION); Localytics.setProfileAttribute("Hometown", "New York, New York", Localytics.ProfileScope.ORGANIZATION); Localytics.setProfileAttribute("States visited", new String[]{"New York", "California", "South Dakota"}, Localytics.ProfileScope.APPLICATION); // to remove a profile attribute: Localytics.deleteProfileAttribute("Days until graduation", Localytics.ProfileScope.APPLICATION); // to add a set of values to an already-defined set of values: Localytics.addProfileAttributesToSet("Lucky numbers", new long[]{666}, Localytics.ProfileScope.APPLICATION); Localytics.addProfileAttributesToSet("Upcoming sales calls", new Date[]{new GregorianCalendar(2015, 4, 19).getTime(), new GregorianCalendar(2015, 12, 24).getTime()}, Localytics.ProfileScope.APPLICATION); Localytics.addProfileAttributesToSet("States visited", new String[]{"North Dakota"}, Localytics.ProfileScope.APPLICATION); // to remove a set of values from an already-defined set of values: Localytics.removeProfileAttributesFromSet("Lucky numbers", new long[]{8, 666}, Localytics.ProfileScope.APPLICATION); Localytics.removeProfileAttributesFromSet("Upcoming sales calls", new Date[]{new GregorianCalendar(2016, 3, 17).getTime()}, Localytics.ProfileScope.APPLICATION); Localytics.removeProfileAttributesFromSet("States visited", new String[]{"California"}, Localytics.ProfileScope.APPLICATION) // to increment or decrement an already-defined value: Localytics.incrementProfileAttribute("Age", 1, Localytics.ProfileScope.ORGANIZATION); Localytics.decrementProfileAttribute("Days until graduation", 3, Localytics.ProfileScope.APPLICATION);