Skip to content

Commit

Permalink
Merge pull request #14 from testfairy/android-sdk
Browse files Browse the repository at this point in the history
Android sdk
Updated to ios sdk 1.7.4
  • Loading branch information
vijaysharm committed Apr 13, 2016
2 parents f448ea8 + 32e70f4 commit c95ddd9
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 8 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
language: objective-c

before_install:
- wget http://dl.google.com/android/android-sdk_r24.4.1-macosx.zip
- unzip android-sdk_r24.4.1-macosx.zip
- export ANDROID_HOME=$PWD/android-sdk-macosx
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools

- echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
- echo yes | android update sdk --filter android-23 --no-ui --force > /dev/null
- echo yes | android update sdk --filter build-tools-23.0.3 --all --no-ui --force > /dev/null
- echo yes | android update sdk --filter sysimg-23 --no-ui --force > /dev/null
- echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
- echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null

install:
- npm install -g cordova

Expand All @@ -8,6 +21,8 @@ script:
- cordova create hello com.example.hello HelloWorld
- cd hello
- cordova platform add ios
- cordova platform add android
- cordova plugin add https://github.com/testfairy/testfairy-cordova-plugin
- cordova build ios
- cordova build android

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Supported Platforms

TestFairy SDK for PhoneGap/Cordova is currently available only for *iOS*. For Android apps, just upload the APK files directly to https://app.testfairy.com.
TestFairy SDK for PhoneGap/Cordova is currently only available for iOS and Android apps.

### Installation

Expand All @@ -16,12 +16,14 @@ cordova plugin add https://github.com/testfairy/testfairy-cordova-plugin

### Usage

Initialize TestFairy with your [App Token](https://app.testfairy.com/settings/#apptoken) by calling `TestFairy.begin` from *onDeviceReady*. For example, here's *onDeviceReady* from *index.js*:
Initialize TestFairy with your [App Token](https://app.testfairy.com/settings/#apptoken) by calling `TestFairy.begin`. Your APP_TOKEN is available at https://app.testfairy.com/settings/#apptoken.

It's recommended to invoke `TestFairy.begin` from `onDeviceReady`. For example, here's *onDeviceReady* from *index.js*:

```
onDeviceReady: function() {
app.receivedEvent('deviceready');
TestFairy.begin("MY_APP_TOKEN");
TestFairy.begin("APP_TOKEN");
},
```

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "com.testfairy.cordova-plugin",
"version": "1.7.0",
"version": "2.0.0",
"description": "TestFairy SDK plugin for Cordova",
"cordova": {
"id": "com.testfairy.cordova-plugin",
"platforms": [
"ios"
"ios",
"android"
]
},
"repository": {
Expand All @@ -20,6 +21,7 @@
"distribution",
"testflight",
"cordova-ios",
"cordova-android",
"ecosystem:cordova"
],
"author": "Apache Software Foundation",
Expand All @@ -29,3 +31,4 @@
},
"homepage": "https://github.com/testfairy/testfairy-cordova-plugin"
}

15 changes: 12 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.testfairy.cordova-plugin" version="1.7.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.testfairy.cordova-plugin" version="2.0.0">
<name>TestFairy Plugin</name>
<description>TestFairy SDK plugin for Cordova</description>
<license>Apache 2.0 License</license>
<engines>
<engine name="cordova" version=">=2.9.0" />
<!--
<!--
<engine name="cordova-android" version=">=3.1.0" />
-->
-->
</engines>

<js-module src="www/testfairy.js" name="TestFairy">
Expand All @@ -34,4 +34,13 @@
<framework src="OpenGLES.framework" />
<framework src="CoreLocation.framework" />
</platform>
<platform name="android">
<source-file src="src/android/CDVTestFairy.java" target-dir="src/com/testfairy" />
<source-file src="src/android/testfairy-sdk.jar" target-dir="libs" />
<config-file target="config.xml" parent="/widget">
<feature name="TestFairy">
<param name="android-package" value="com.testfairy.CDVTestFairy" />
</feature>
</config-file>
</platform>
</plugin>
39 changes: 39 additions & 0 deletions src/android/CDVTestFairy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.testfairy;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaInterface;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;
import android.content.Intent;

import android.content.Context;

public class CDVTestFairy extends CordovaPlugin {
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if ("begin".equals(action)) {
String apiKey = args.optString(0);
TestFairy.begin(cordova.getActivity(), apiKey);
} else if ("pushFeedbackController".equals(action)) {

} else if ("updateLocation".equals(action)) {

} else if ("checkpoint".equals(action)) {
String name = args.optString(0);
TestFairy.addCheckpoint(name);
} else if ("setCorrelationId".equals(action)) {
String id = args.optString(0);
TestFairy.setCorrelationId(id);
} else if ("pause".equals(action)) {
TestFairy.pause();
} else if ("resume".equals(action)) {
TestFairy.resume();
} else {
return false;
}

callbackContext.success();
return true;
}
}
Binary file added src/android/testfairy-sdk.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions src/ios/TestFairy.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ extern NSString *const TFSDKIdentityTraitWebsiteAddressKey;
extern NSString *const TFSDKIdentityTraitAgeKey;
extern NSString *const TFSDKIdentityTraitSignupDateKey;
extern NSString *const TFSDKEnableCrashReporterKey;
extern NSString *const TestFairyDidShakeDevice;
extern NSString *const TestFairyWillProvideFeedback;
extern NSString *const TestFairyDidCancelFeedback;
extern NSString *const TestFairyDidSendFeedback;

Binary file modified src/ios/libTestFairy.a
Binary file not shown.
85 changes: 85 additions & 0 deletions src/ios/upload-dsym.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/sh

TESTFAIRY_ENDPOINT="http://app.testfairy.com/upload/dsym/"

ZIP=zip
CURL=curl
STAT=stat
DATE=date

log() {
NOW=$($DATE +"%Y-%m-%d %H:%M:%S")
echo "${NOW} ${1}"
}

help() {
echo "Usage: ${0} [-f] TESTFAIRY_API_KEY [-p DSYM_PATH]"
exit 1
}

DAEMON=1
if [ "${1}" == "-f" ]; then
DAEMON=0
shift
elif [ "${1}" == "-d" ]; then
# backward compatible when -f was the default
shift
fi


API_KEY="${1}"
if [ ! "${API_KEY}" ]; then
help
fi

DSYM_PATH=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}

if [ "${#}" -gt 1 ]; then
shift
if [ "${1}" != "-p" ]; then
help
fi

shift
DSYM_PATH="${1}"
fi

if [ "${DSYM_PATH}" == "" ] || [ "${DSYM_PATH}" == "/" ] || [ ! -d "${DSYM_PATH}" ]; then
echo "Fatal: Can't find .dSYM folder!"
help
fi

NOW=$($DATE +%s)
TMP_FILENAME="/tmp/${NOW}-${DWARF_DSYM_FILE_NAME}.zip"

# Compress the .dSYM folder into a zip file
log "Compressing .dSYM folder ${DSYM_PATH}"
$ZIP -qrp9 "${TMP_FILENAME}" "${DSYM_PATH}"
FILE_SIZE=$($STAT -f "%z" "${TMP_FILENAME}")

foreground_upload() {
# Upload zipped .dSYM file to TestFairy's servers
STARTED=$($DATE +"%s")
$CURL -s -F api_key="${API_KEY}" -F dsym=@"${1}" -o /dev/null "${TESTFAIRY_ENDPOINT}"
ENDED=$($DATE +"%s")
DIFF=$(expr ${ENDED} - ${STARTED})
log "Symbols uploaded in ${DIFF} seconds"

# Clean up behind
rm -f ${TMP_FILENAME}
}

background_upload() {
sh -c "$CURL -F api_key=\"${API_KEY}\" -F dsym=@\"${1}\" -s -o /dev/null \"${TESTFAIRY_ENDPOINT}\"; rm -f ${TMP_FILENAME};" /dev/null 2>&1 &
}

if [ "$DAEMON" == "0" ]; then
log "Uploading ${FILE_SIZE} bytes to dsym server in foreground"
foreground_upload "${TMP_FILENAME}"
else
log "Uploading ${FILE_SIZE} bytes to dsym server in background"
background_upload "${TMP_FILENAME}"
fi

log "TestFairy .dSYM upload script ends"

0 comments on commit c95ddd9

Please sign in to comment.