-
- All Implemented Interfaces:
public class Apptentive
-
-
Field Summary
Fields Modifier and Type Field Description private final Booleanregisteredprivate final static Observable<EventNotification>eventNotificationObservableprivate final static Observable<MessageCenterNotification>messageCenterNotificationObservableprivate final IntegerAPPTENTIVE_NOTIFICATION_IDprivate final IntegerPUSH_PROVIDER_APPTENTIVEprivate final IntegerPUSH_PROVIDER_PARSEprivate final IntegerPUSH_PROVIDER_URBAN_AIRSHIPprivate final IntegerPUSH_PROVIDER_AMAZON_AWS_SNSpublic final static ApptentiveINSTANCE
-
Method Summary
Modifier and Type Method Description final static UnitregisterApptentiveActivityInfoCallback(ApptentiveActivityInfo apptentiveActivityInfo)Collects the ApptentiveActivityInfo reference which can be used to retrieve the current Activity's Context. final BooleanisApptentiveActivityInfoCallbackRegistered()Util method to check if the ApptentiveActivityInfo is registered final static UnitunregisterApptentiveActivityInfoCallback()Optional method: Clears the ApptentiveActivityInfo final ApptentiveActivityInfogetApptentiveActivityCallback()final static Unitregister(Application application, ApptentiveConfiguration configuration, RegisterCallback callback)final static Unitregister(Application application, ApptentiveConfiguration configuration)final Unitregister(Application application, ApptentiveConfiguration configuration, Function1<RegisterResult, Unit> callback)This method registers the Apptentive SDK using the given SDK credentials in the ApptentiveConfiguration It must be called from the Application#onCreate() method in the Application object defined in your app's manifest. final static Unitlogin(String jwtToken, Function1<LoginResult, Unit> callback)Starts login process asynchronously. final BooleanisRegistered()Returns whether or not the register() method is already called. final static Unitlogout()final UnitsetAuthenticationFailedListener(AuthenticationFailedListener listener)Registers your listener with Apptentive. final static UnitupdateToken(String jwtToken, Function1<LoginResult, Unit> callback)final SDKStategetCurrentState()final static Unitengage(String eventName, Map<String, Object> customData, EngagementCallback callback)This method takes a unique event of type String, stores a record of that event having been visited, determines if there is an interaction that is able to run for this event, and then runs it. final static Unitengage(String eventName, Map<String, Object> customData)This method takes a unique event of type String, stores a record of that event having been visited, determines if there is an interaction that is able to run for this event, and then runs it. final static Unitengage(String eventName)This method takes a unique event of type String, stores a record of that event having been visited, determines if there is an interaction that is able to run for this event, and then runs it. final static BooleancanShowInteraction(String eventName)Returns whether or not an engage event will display an Interaction. final static UnitshowMessageCenter(Map<String, Object> customData, EngagementCallback callback)Opens the Apptentive Message Center. final static UnitshowMessageCenter(Map<String, Object> customData)Opens the Apptentive Message Center. final static UnitshowMessageCenter()Opens the Apptentive Message Center. final static UnitcanShowMessageCenter(BooleanCallback callback)Our SDK must connect to our server at least once to download initial configuration for Message Center. final static BooleancanShowMessageCenter()final static IntegergetUnreadMessageCount()Returns the number of unread messages in the Message Center. final static UnitsendAttachmentText(String text)Sends a text message to the server. final static UnitsendAttachmentFile(String uri)Sends a file to the server. final static UnitsendAttachmentFile(ByteArray content, String mimeType)Sends a file to the server. final static UnitsendAttachmentFile(InputStream inputStream, String mimeType)Sends a file to the server. final static UnitsetPersonName(String name)Sets the user's name. final static StringgetPersonName()Retrieves the user's name. final static UnitsetPersonEmail(String email)Sets the user's email address. final static StringgetPersonEmail()Retrieves the user's email address. final static UnitaddCustomPersonData(String key, String value)Add a custom data String to the Person. final static UnitaddCustomPersonData(String key, Number value)Add a custom data Number to the Person. final static UnitaddCustomPersonData(String key, Boolean value)Add a custom data Boolean to the Person. final static UnitremoveCustomPersonData(String key)Remove a piece of custom data from the Person. final static UnitsetMParticleId(String id)Sets the mParticleId of the user. final static UnitaddCustomDeviceData(String key, String value)Add a custom data String to the Device. final static UnitaddCustomDeviceData(String key, Number value)Add a custom data Number to the Device. final static UnitaddCustomDeviceData(String key, Boolean value)Add a custom data Boolean to the Device. final static UnitremoveCustomDeviceData(String key)Remove a piece of custom data from the device. final static UnitsetPushNotificationIntegration(Context context, Integer pushProvider, String token)Sends push provider information to our server to allow us to send pushes to this device when you reply to your customers. final static BooleanisApptentivePushNotification(Intent intent)Determines whether this Intent is a push notification sent from Apptentive. final static BooleanisApptentivePushNotification(Map<String, String> data)Determines whether push payload data came from an Apptentive Push Notification. final static UnitbuildPendingIntentFromPushNotification(Context context, PendingIntentCallback callback, Intent intent)Use this method in your push receiver to build a PendingIntent when an Apptentive push notification is received. final static UnitbuildPendingIntentFromPushNotification(Context context, PendingIntentCallback callback, Map<String, String> data)Use this method in your push receiver to build a pending Intent when an Apptentive push notification is received. final static StringgetTitleFromApptentivePush(Intent intent)Use this method in your push receiver to get the notification title you can use to construct an android.app.Notification object. final static StringgetTitleFromApptentivePush(Bundle bundle)Use this method in your push receiver to get the notification title you can use to construct a android.app.Notification object. final static StringgetTitleFromApptentivePush(Map<String, String> data)Use this method in your push receiver to get the notification title you can use to construct a android.app.Notification object. final static StringgetBodyFromApptentivePush(Intent intent)Use this method in your push receiver to get the notification body text you can use to construct an android.app.Notification object. final static StringgetBodyFromApptentivePush(Bundle bundle)Use this method in your push receiver to get the notification body text you can use to construct a android.app.Notification object. final static StringgetBodyFromApptentivePush(Map<String, String> data)Use this method in your push receiver to get the notification body text you can use to construct a android.app.Notification object. final BooleansetLocalManifest(String json)final BooleangetRegistered()final static Observable<EventNotification>getEventNotificationObservable()final static Observable<MessageCenterNotification>getMessageCenterNotificationObservable()final IntegergetAPPTENTIVE_NOTIFICATION_ID()Use this ID when you call notifyfor Apptentive Push Notifications if you want notifications to be cleared when when Message Center is shown.final IntegergetPUSH_PROVIDER_APPTENTIVE()Call setPushNotificationIntegration with one of the below values to allow Apptentive to send push notifications to this device. final IntegergetPUSH_PROVIDER_PARSE()final IntegergetPUSH_PROVIDER_URBAN_AIRSHIP()final IntegergetPUSH_PROVIDER_AMAZON_AWS_SNS()-
-
Method Detail
-
registerApptentiveActivityInfoCallback
final static Unit registerApptentiveActivityInfoCallback(ApptentiveActivityInfo apptentiveActivityInfo)
Collects the ApptentiveActivityInfo reference which can be used to retrieve the current Activity's Context. The retrieved context is used in the Apptentive interactions & its UI elements.
- Parameters:
apptentiveActivityInfo- reference to the app's current Activity
-
isApptentiveActivityInfoCallbackRegistered
final Boolean isApptentiveActivityInfoCallbackRegistered()
Util method to check if the ApptentiveActivityInfo is registered
-
unregisterApptentiveActivityInfoCallback
final static Unit unregisterApptentiveActivityInfoCallback()
Optional method: Clears the ApptentiveActivityInfo
-
getApptentiveActivityCallback
final ApptentiveActivityInfo getApptentiveActivityCallback()
-
register
@JvmOverloads()@Synchronized() final static Unit register(Application application, ApptentiveConfiguration configuration, RegisterCallback callback)
-
register
@JvmOverloads()@Synchronized() final static Unit register(Application application, ApptentiveConfiguration configuration)
-
register
@Synchronized() final Unit register(Application application, ApptentiveConfiguration configuration, Function1<RegisterResult, Unit> callback)
This method registers the Apptentive SDK using the given SDK credentials in the ApptentiveConfiguration It must be called from the Application#onCreate() method in the Application object defined in your app's manifest.
- Parameters:
application- Application object.configuration- ApptentiveConfiguration containing SDK initialization data.callback- Returns a callback of an RegisterResult.
-
login
@Synchronized() final static Unit login(String jwtToken, Function1<LoginResult, Unit> callback)
Starts login process asynchronously. This call returns immediately. Using this method requires you to implement JWT generation on your server. Please read about it in Apptentive's Android Integration Reference Guide.
- Parameters:
jwtToken- A JWT signed by your server using the secret from your app's Apptentive settings.callback- A LoginCallback, which will be called asynchronously when the login succeeds or fails.
-
isRegistered
final Boolean isRegistered()
Returns whether or not the register() method is already called.
-
logout
@Synchronized() final static Unit logout()
-
setAuthenticationFailedListener
final Unit setAuthenticationFailedListener(AuthenticationFailedListener listener)
Registers your listener with Apptentive. This listener is stored with a WeakReference, which means that you must store a static reference to the listener as long as you want it to live. One possible way to do this is to implement this listener with your Application class, or store one on your Application.
This listener will alert you to authentication failures, so that you can either recover from expired or revoked JWTs, or fix your authentication implementation.
- Parameters:
listener- A listener that will be called when there is an authentication failure other for the current logged in conversation.
-
updateToken
@Synchronized() final static Unit updateToken(String jwtToken, Function1<LoginResult, Unit> callback)
-
getCurrentState
final SDKState getCurrentState()
-
engage
@JvmOverloads() final static Unit engage(String eventName, Map<String, Object> customData, EngagementCallback callback)
This method takes a unique event of type String, stores a record of that event having been visited, determines if there is an interaction that is able to run for this event, and then runs it. Only one interaction at most will run per invocation of this method. This task is performed asynchronously.
- Parameters:
eventName- A unique String representing the line this method is called on.customData- Extra data sent with the engaged event.callback- Returns EngagementCallback of an EngagementResult.
-
engage
@JvmOverloads() final static Unit engage(String eventName, Map<String, Object> customData)
This method takes a unique event of type String, stores a record of that event having been visited, determines if there is an interaction that is able to run for this event, and then runs it. Only one interaction at most will run per invocation of this method. This task is performed asynchronously.
- Parameters:
eventName- A unique String representing the line this method is called on.customData- Extra data sent with the engaged event.
-
engage
@JvmOverloads() final static Unit engage(String eventName)
This method takes a unique event of type String, stores a record of that event having been visited, determines if there is an interaction that is able to run for this event, and then runs it. Only one interaction at most will run per invocation of this method. This task is performed asynchronously.
- Parameters:
eventName- A unique String representing the line this method is called on.
-
canShowInteraction
final static Boolean canShowInteraction(String eventName)
Returns whether or not an engage event will display an Interaction.
See the Can Show Interaction section of the Apptentive Learn documentation for more info.
-
showMessageCenter
@JvmOverloads() final static Unit showMessageCenter(Map<String, Object> customData, EngagementCallback callback)
Opens the Apptentive Message Center. This operation is performed asynchronously.
- Parameters:
customData- Extra data sent with messages in Message Center.callback- Returns EngagementCallback of an EngagementResult
-
showMessageCenter
@JvmOverloads() final static Unit showMessageCenter(Map<String, Object> customData)
Opens the Apptentive Message Center. This operation is performed asynchronously.
- Parameters:
customData- Extra data sent with messages in Message Center.
-
showMessageCenter
@JvmOverloads() final static Unit showMessageCenter()
Opens the Apptentive Message Center. This operation is performed asynchronously.
-
canShowMessageCenter
final static Unit canShowMessageCenter(BooleanCallback callback)
Our SDK must connect to our server at least once to download initial configuration for Message Center. Call this method to see whether or not Message Center can be displayed. This task is performed asynchronously.
- Parameters:
callback- Called after we check to see if Message Center can be displayed, but before it is displayed.
-
canShowMessageCenter
final static Boolean canShowMessageCenter()
-
getUnreadMessageCount
final static Integer getUnreadMessageCount()
Returns the number of unread messages in the Message Center.
This should be called after Apptentive is started. If this is called before Apptentive finishes initializing for the first time then it may not work.
-
sendAttachmentText
final static Unit sendAttachmentText(String text)
Sends a text message to the server. This message will be visible in the conversation view on the server, but will not be shown in the client's Message Center.
- Parameters:
text- The message you wish to send.
-
sendAttachmentFile
final static Unit sendAttachmentFile(String uri)
Sends a file to the server. This file will be visible in the conversation view on the server, but will not be shown in the client's Message Center. A local copy of this file will be made until the message is transmitted, at which point the temporary file will be deleted.
NOTICE: FILE SIZE LIMIT IS 15MB
- Parameters:
uri- The URI path of the local resource file.
-
sendAttachmentFile
final static Unit sendAttachmentFile(ByteArray content, String mimeType)
Sends a file to the server. This file will be visible in the conversation view on the server, but will not be shown in the client's Message Center. A local copy of this file will be made until the message is transmitted, at which point the temporary file will be deleted.
NOTICE: FILE SIZE LIMIT IS 15MB
- Parameters:
content- A byte array of the file contents.mimeType- The mime type of the file.
-
sendAttachmentFile
final static Unit sendAttachmentFile(InputStream inputStream, String mimeType)
Sends a file to the server. This file will be visible in the conversation view on the server, but will not be shown in the client's Message Center. A local copy of this file will be made until the message is transmitted, at which point the temporary file will be deleted.
NOTICE: FILE SIZE LIMIT IS 15MB
- Parameters:
inputStream- An InputStream from the desired file.mimeType- The mime type of the file.
-
setPersonName
final static Unit setPersonName(String name)
Sets the user's name. This name will be sent to the Apptentive server and displayed in conversations you have with this person. This name will be the definitive username for this user, unless one is provided directly by the user through an Apptentive UI. Calls to this method are idempotent. Calls to this method will overwrite any previously entered person's name. You can check the value with getPersonName.
nullor blank strings will fail to be set on the server so we don't attempt.- Parameters:
name- The user's name.
-
getPersonName
final static String getPersonName()
Retrieves the user's name. This name may be set via setPersonName, or by the user through Message Center.
-
setPersonEmail
final static Unit setPersonEmail(String email)
Sets the user's email address. This email address will be sent to the Apptentive server to allow out of app communication, and to help provide more context about this user. This email will be the definitive email address for this user, unless one is provided directly by the user through an Apptentive UI. Calls to this method are idempotent. Calls to this method will overwrite any previously entered email, so if you don't want to overwrite any previously entered email. You can check the value with getPersonEmail.
nullor blank strings will fail to be set on the server so we don't attempt.- Parameters:
email- The user's email address.
-
getPersonEmail
final static String getPersonEmail()
Retrieves the user's email address. This address may be set via setPersonEmail, or by the user through Message Center.
-
addCustomPersonData
final static Unit addCustomPersonData(String key, String value)
Add a custom data String to the Person. Custom data will be sent to the server, is displayed in the Conversation view, and can be used in Interaction targeting. Calls to this method are idempotent.
- Parameters:
key- The key to store the data under.value- A String value.
-
addCustomPersonData
final static Unit addCustomPersonData(String key, Number value)
Add a custom data Number to the Person. Custom data will be sent to the server, is displayed in the Conversation view, and can be used in Interaction targeting. Calls to this method are idempotent.
- Parameters:
key- The key to store the data under.value- A Number value.
-
addCustomPersonData
final static Unit addCustomPersonData(String key, Boolean value)
Add a custom data Boolean to the Person. Custom data will be sent to the server, is displayed in the Conversation view, and can be used in Interaction targeting. Calls to this method are idempotent.
- Parameters:
key- The key to store the data under.value- A Boolean value.
-
removeCustomPersonData
final static Unit removeCustomPersonData(String key)
Remove a piece of custom data from the Person. Calls to this method are idempotent.
- Parameters:
key- The key to remove.
-
setMParticleId
final static Unit setMParticleId(String id)
Sets the mParticleId of the user. It is used to associate a MParticle user with a conversation in Apptentive dashboard
- Parameters:
id- The mParticleId of the person.
-
addCustomDeviceData
final static Unit addCustomDeviceData(String key, String value)
Add a custom data String to the Device. Custom data will be sent to the server, is displayed in the Conversation view, and can be used in Interaction targeting. Calls to this method are idempotent.
- Parameters:
key- The key to store the data under.value- A String value.
-
addCustomDeviceData
final static Unit addCustomDeviceData(String key, Number value)
Add a custom data Number to the Device. Custom data will be sent to the server, is displayed in the Conversation view, and can be used in Interaction targeting. Calls to this method are idempotent.
- Parameters:
key- The key to store the data under.value- A Number value.
-
addCustomDeviceData
final static Unit addCustomDeviceData(String key, Boolean value)
Add a custom data Boolean to the Device. Custom data will be sent to the server, is displayed in the Conversation view, and can be used in Interaction targeting. Calls to this method are idempotent.
- Parameters:
key- The key to store the data under.value- A Boolean value.
-
removeCustomDeviceData
final static Unit removeCustomDeviceData(String key)
Remove a piece of custom data from the device. Calls to this method are idempotent.
- Parameters:
key- The key to remove.
-
setPushNotificationIntegration
final static Unit setPushNotificationIntegration(Context context, Integer pushProvider, String token)
Sends push provider information to our server to allow us to send pushes to this device when you reply to your customers. Only one push provider is allowed to be active at a time, so you should only call this method once. Please see our integration guide for instructions.
- Parameters:
pushProvider- One of the following:token- The push provider token you receive from your push provider.
-
isApptentivePushNotification
final static Boolean isApptentivePushNotification(Intent intent)
Determines whether this Intent is a push notification sent from Apptentive.
- Parameters:
intent- The received Intent you received in your BroadcastReceiver.
-
isApptentivePushNotification
final static Boolean isApptentivePushNotification(Map<String, String> data)
Determines whether push payload data came from an Apptentive Push Notification. This method is also used for Urban Airship.
- Parameters:
data- The push payload data obtained through FCMonMessageReceived(), when using FCM
-
buildPendingIntentFromPushNotification
final static Unit buildPendingIntentFromPushNotification(Context context, PendingIntentCallback callback, Intent intent)
Use this method in your push receiver to build a PendingIntent when an Apptentive push notification is received. Pass the generated PendingIntent to androidx.core.app.NotificationCompat.Builder.setContentIntent to allow Apptentive to display Interactions such as Message Center. Calling this method for a push Intent that did not come from Apptentive will return a null object. If you receive a
nullobject, your app will need to handle this notification itself.This task is performed asynchronously.
This is the method you will likely need if you integrated using Urban Airship, AWS/SNS, or Parse
- Parameters:
callback- Called after we check to see Apptentive can launch an Interaction from this push.intent- An Intent containing the Apptentive Push data.
-
buildPendingIntentFromPushNotification
final static Unit buildPendingIntentFromPushNotification(Context context, PendingIntentCallback callback, Map<String, String> data)
Use this method in your push receiver to build a pending Intent when an Apptentive push notification is received. Pass the generated PendingIntent to androidx.core.app.NotificationCompat.Builder.setContentIntent to allow Apptentive to display Interactions such as Message Center. Calling this method for a push Bundle that did not come from Apptentive will return a null object. If you receive a null object, your app will need to handle this notification itself.
This task is performed asynchronously.
This is the method you will likely need if you integrated using Firebase Cloud Messaging or Urban Airship
-
getTitleFromApptentivePush
final static String getTitleFromApptentivePush(Intent intent)
Use this method in your push receiver to get the notification title you can use to construct an android.app.Notification object.
- Parameters:
intent- An Intent containing the Apptentive Push data.
-
getTitleFromApptentivePush
final static String getTitleFromApptentivePush(Bundle bundle)
Use this method in your push receiver to get the notification title you can use to construct a android.app.Notification object.
- Parameters:
bundle- A Bundle containing the Apptentive Push data.
-
getTitleFromApptentivePush
final static String getTitleFromApptentivePush(Map<String, String> data)
Use this method in your push receiver to get the notification title you can use to construct a android.app.Notification object.
-
getBodyFromApptentivePush
final static String getBodyFromApptentivePush(Intent intent)
Use this method in your push receiver to get the notification body text you can use to construct an android.app.Notification object.
- Parameters:
intent- An Intent containing the Apptentive Push data.
-
getBodyFromApptentivePush
final static String getBodyFromApptentivePush(Bundle bundle)
Use this method in your push receiver to get the notification body text you can use to construct a android.app.Notification object.
- Parameters:
bundle- A Bundle containing the Apptentive Push data.
-
getBodyFromApptentivePush
final static String getBodyFromApptentivePush(Map<String, String> data)
Use this method in your push receiver to get the notification body text you can use to construct a android.app.Notification object.
-
setLocalManifest
final Boolean setLocalManifest(String json)
-
getRegistered
@Synchronized() final Boolean getRegistered()
-
getEventNotificationObservable
final static Observable<EventNotification> getEventNotificationObservable()
-
getMessageCenterNotificationObservable
final static Observable<MessageCenterNotification> getMessageCenterNotificationObservable()
-
getAPPTENTIVE_NOTIFICATION_ID
final Integer getAPPTENTIVE_NOTIFICATION_ID()
Use this ID when you call
notifyfor Apptentive Push Notifications if you want notifications to be cleared when when Message Center is shown.
-
getPUSH_PROVIDER_APPTENTIVE
final Integer getPUSH_PROVIDER_APPTENTIVE()
Call setPushNotificationIntegration with one of the below values to allow Apptentive to send push notifications to this device.
PUSH_PROVIDER_APPTENTIVE - Requires a valid Firebase Cloud Messaging (FCM) configuration.
PUSH_PROVIDER_PARSE - Requires a valid Parse integration.
PUSH_PROVIDER_URBAN_AIRSHIP - Requires a valid Urban Airship Push integration.
PUSH_PROVIDER_AMAZON_AWS_SNS - Requires a valid Amazon Web Services (AWS) Simple Notification Service (SNS) integration.
-
getPUSH_PROVIDER_PARSE
final Integer getPUSH_PROVIDER_PARSE()
-
getPUSH_PROVIDER_URBAN_AIRSHIP
final Integer getPUSH_PROVIDER_URBAN_AIRSHIP()
-
getPUSH_PROVIDER_AMAZON_AWS_SNS
final Integer getPUSH_PROVIDER_AMAZON_AWS_SNS()
-
-
-
-