@Test
 public void wrongActionKey() {
   Bundle bundle = new Bundle();
   bundle.putString("apptentive", wrongKey);
   assertNull(Apptentive.buildPendingIntentFromPushNotification(bundle));
   assertTrue(Apptentive.isApptentivePushNotification(bundle));
 }
 @Test
 public void corrupt() {
   Bundle bundle = new Bundle();
   bundle.putString("apptentive", corrupt);
   assertNull(Apptentive.buildPendingIntentFromPushNotification(bundle));
   assertTrue(Apptentive.isApptentivePushNotification(bundle));
 }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // OPTIONAL: To specify a different user email than what the device was setup with.
    // Apptentive.setInitialUserEmail(this, "*****@*****.**");

    // OPTIONAL: To send extra about the device to the server.
    // Apptentive.addCustomDeviceData(this, "custom_device_key", "custom_device_value");
    // Apptentive.addCustomPersonData(this, "custom_person_key", "custom_person_value");

    // OPTIONAL: Specify a different rating provider if your app is not served from Google Play.
    // Apptentive.setRatingProvider(new AmazonAppstoreRatingProvider());

    // Impersonate an app for ratings.
    // Apptentive.putRatingProviderArg("package", "your.package.name");

    // If you would like to be notified when there are unread messages available, set a listener
    // like this.
    Apptentive.setUnreadMessagesListener(
        new UnreadMessagesListener() {
          public void onUnreadMessageCountChanged(final int unreadMessages) {
            Log.e(LOG_TAG, "There are " + unreadMessages + " unread messages.");
            runOnUiThread(
                new Runnable() {
                  public void run() {
                    Button messageCenterButton = (Button) findViewById(R.id.button_message_center);
                    if (messageCenterButton != null) {
                      messageCenterButton.setText("Message Center, unread = " + unreadMessages);
                    }
                    if (lastUnreadMessageCount != unreadMessages) {
                      Toast.makeText(
                              MainActivity.this,
                              "You have " + unreadMessages + " unread messages.",
                              Toast.LENGTH_SHORT)
                          .show();
                    }
                    lastUnreadMessageCount = unreadMessages;
                  }
                });
          }
        });

    // Ad a listener to notify you when a survey is completed.
    Apptentive.setOnSurveyFinishedListener(
        new OnSurveyFinishedListener() {
          @Override
          public void onSurveyFinished(boolean completed) {
            Toast.makeText(
                    MainActivity.this,
                    completed ? "Survey was completed." : "Survey was skipped.",
                    Toast.LENGTH_SHORT)
                .show();
          }
        });
  }
Esempio n. 4
0
 public void addCustomPersonData(@SuppressWarnings("unused") View view) {
   EditText keyText = (EditText) findViewById(R.id.add_custom_person_data_key);
   EditText valueText = (EditText) findViewById(R.id.add_custom_person_data_value);
   String key = (keyText).getText().toString().trim();
   String value = (valueText).getText().toString().trim();
   keyText.setText(null);
   valueText.setText(null);
   Apptentive.addCustomPersonData(this, key, value);
 }
Esempio n. 5
0
 public static void isSurveyAvailable(
     final ForgeTask task, @ForgeParam("tags") final JsonArray surveyTags) {
   Log.e("Tags: " + surveyTags.toString());
   String[] tags = new String[surveyTags.size()];
   for (int i = 0; i < surveyTags.size(); i++) {
     tags[i] = surveyTags.get(i).getAsString();
   }
   boolean available = Apptentive.isSurveyAvailable(ForgeApp.getActivity(), tags);
   task.success(available);
 }
 @Test
 public void good() throws Throwable {
   final Bundle bundle = new Bundle();
   bundle.putString("apptentive", good);
   uiThreadTestRule.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           assertNotNull(Apptentive.buildPendingIntentFromPushNotification(bundle));
         }
       });
   assertTrue(Apptentive.isApptentivePushNotification(bundle));
 }
 public void showMessageCenter(@SuppressWarnings("unused") View view) {
   Apptentive.showMessageCenter(this);
 }
 @Test
 public void missingApptentive() {
   Bundle bundle = new Bundle();
   assertNull(Apptentive.buildPendingIntentFromPushNotification(bundle));
   assertFalse(Apptentive.isApptentivePushNotification(bundle));
 }
Esempio n. 9
0
 public void removeCustomPersonData(@SuppressWarnings("unused") View view) {
   EditText keyText = (EditText) findViewById(R.id.remove_custom_person_data_key);
   String key = (keyText).getText().toString().trim();
   keyText.setText(null);
   Apptentive.removeCustomPersonData(this, key);
 }
 private static PayloadStore getPayloadStore(Context context) {
   return Apptentive.getDatabase(context);
 }
Esempio n. 11
0
 public static void getUnreadMessageCount(final ForgeTask task) {
   int count = Apptentive.getUnreadMessageCount(ForgeApp.getActivity());
   task.success(new JsonPrimitive(count));
 }
Esempio n. 12
0
 public static void logSignificantEvent(final ForgeTask task) {
   Apptentive.logSignificantEvent(ForgeApp.getActivity());
 }
Esempio n. 13
0
 public static void removeCustomPersonData(
     final ForgeTask task, @ForgeParam("key") final String key) {
   Apptentive.removeCustomPersonData(ForgeApp.getActivity(), key);
 }
Esempio n. 14
0
 public static void addCustomPersonData(
     final ForgeTask task,
     @ForgeParam("key") final String key,
     @ForgeParam("value") final String value) {
   Apptentive.addCustomPersonData(ForgeApp.getActivity(), key, value);
 }
Esempio n. 15
0
 public static void setInitialUserEmailAddress(
     final ForgeTask task,
     @ForgeParam("initialUserEmailAddress") final String initialUserEmailAddress) {
   Apptentive.setInitialUserEmail(ForgeApp.getActivity(), initialUserEmailAddress);
   task.success();
 }