Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated sdks, added --variables #9

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ SDK documentation and integration guides for IOS and Android:
http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/hockeyapp-for-ios
http://support.hockeyapp.net/kb/client-integration-android-other-platforms/hockeyapp-for-android-sdk

TODO - update plugin to latest SDK versions

## Installation

#### Automatic Installation using PhoneGap/Cordova CLI (iOS and Android)
Expand All @@ -24,17 +22,5 @@ TODO - update plugin to latest SDK versions

2. Install this plugin using PhoneGap/Cordova cli:

cordova plugin add https://github.com/wnyc/cordova-plugin-hockeyapp.git

3. For iOS, modify HockeyAppPlugin.m, replacing with your configuration setting:

NSString * hockeyAppKey = @"__HOCKEY_APP_KEY__";

For Android, modify HockeyAppPlugin.java, replacing with your configuration setting:

String hockeyAppId="__HOCKEY_APP_KEY__";

Todo: better way to turn update check on/off (Android only) than having build script comment out code between __HOCKEY_APP_UPDATE_ACTIVE_START__ and __HOCKEY_APP_UPDATE_ACTIVE_END__ in HockeyAppPlugin.java

Todo: pull GA key from configuration setting
cordova plugin add https://github.com/wnyc/cordova-plugin-hockeyapp.git --variable IOS_API_KEY="YOUR_IOS_APP_API_KEY" --variable ANDROID_API_KEY="YOUR_ANDROID_APP_API_KEY" --variable IS_STORE=true

21 changes: 15 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

<!-- android -->
<platform name="android">
<preference name="ANDROID_API_KEY"/>

<config-file target="res/xml/config.xml" parent="/*">
<feature name="HockeyAppPlugin" >
<param name="android-package" value="org.nypr.cordova.hockeyappplugin.HockeyAppPlugin"/>
Expand All @@ -32,30 +34,38 @@
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="net.hockeyapp.android.UpdateActivity" />
</config-file>
<config-file target="AndroidManifest.xml" parent="application">
<meta-data android:name="hockey_app_api_key" android:value="$ANDROID_API_KEY"/>
</config-file>

<source-file src="src/android/HockeyAppPlugin.java" target-dir="src/org/nypr/cordova/hockeyappplugin/" />
<source-file src="src/android/HockeySDK-3.0.2.jar" target-dir="libs" />
<source-file src="src/android/HockeySDK-3.6.2.jar" target-dir="libs" />
</platform>

<!-- ios -->
<platform name="ios">
<preference name="IOS_API_KEY"/>

<config-file target="config.xml" parent="/*">
<feature name="HockeyAppPlugin">
<param name="ios-package" value="HockeyAppPlugin" />
<param name="onload" value="true" />
</feature>
</config-file>

<config-file target="*-Info.plist" parent="HockeyAppApiKey">
<string>$IOS_API_KEY</string>
</config-file>

<dependency id="org.nypr.cordova.nslogger-cocoalumberjack-connector-plugin" url="https://github.com/wnyc/cordova-plugin-nslogger-cocoalumberjack-connector.git" />

<header-file src="src/ios/HockeyAppPlugin.h" />

<source-file src="src/ios/HockeyAppPlugin.m" />

<resource-file src="src/ios/HockeySDK.embeddedframework/Resources/HockeySDKResources.bundle" />
<resource-file src="src/ios/HockeySDK.embeddedframework/Resources/HockeySDK.xcconfig" />
<resource-file src="src/ios/HockeySDK.framework/Resources/HockeySDKResources.bundle" />

<framework src="src/ios/HockeySDK.embeddedframework/HockeySDK.framework" custom="true"/>
<framework src="libc++.tbd" />
<framework src="src/ios/HockeySDK.framework" custom="true"/>
<framework src="AssetsLibrary.framework" />
<framework src="CoreText.framework" />
<framework src="CoreGraphics.framework" />
Expand All @@ -66,6 +76,5 @@
<framework src="Security.framework" />
<framework src="SystemConfiguration.framework" />
<framework src="UIKit.framework" />
<framework src="QuickLook.framework" />
</platform>
</plugin>
29 changes: 21 additions & 8 deletions src/android/HockeyAppPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@
import java.lang.RuntimeException;
import java.lang.Runnable;
import java.lang.Thread;
import java.lang.Exception;

import android.util.Log;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

public class HockeyAppPlugin extends CordovaPlugin {
protected static final String LOG_TAG = "HockeyAppPlugin";
protected String hockeyAppId;
protected Boolean isStore = false;

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);

try{
Context context = cordova.getActivity().getApplicationContext();
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);

hockeyAppId = ai.metaData.getString("hockey_app_api_key");
} catch (Exception e) {
Log.e(LOG_TAG, "Unexpected error while reading application info.", e);
}

_checkForCrashes();
_checkForUpdates();
Log.d(LOG_TAG, "HockeyApp Plugin initialized");
Expand Down Expand Up @@ -66,20 +82,17 @@ public void onReset() {

protected void _checkForCrashes() {
Log.d(LOG_TAG, "HockeyApp Plugin checking for crashes");
String hockeyAppId="__HOCKEY_APP_KEY__"; // replaced by build script. better to pull from a a config file?
if(hockeyAppId!=null && !hockeyAppId.equals("") && !hockeyAppId.contains("HOCKEY_APP_KEY")){
CrashManager.register(cordova.getActivity(), hockeyAppId);
}
}

protected void _checkForUpdates() {
// Remove this for store builds!
//__HOCKEY_APP_UPDATE_ACTIVE_START__
Log.d(LOG_TAG, "HockeyApp Plugin checking for updates");
String hockeyAppId="__HOCKEY_APP_KEY__";
if(hockeyAppId!=null && !hockeyAppId.equals("") && !hockeyAppId.contains("HOCKEY_APP_KEY")){
UpdateManager.register(cordova.getActivity(), hockeyAppId);
if(isStore == false){
Log.d(LOG_TAG, "HockeyApp Plugin checking for updates");
if(hockeyAppId!=null && !hockeyAppId.equals("") && !hockeyAppId.contains("HOCKEY_APP_KEY")){
UpdateManager.register(cordova.getActivity(), hockeyAppId);
}
}
//__HOCKEY_APP_UPDATE_ACTIVE_END__
}
}
Binary file removed src/android/HockeySDK-3.0.2.jar
Binary file not shown.
Binary file added src/android/HockeySDK-3.6.2.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion src/ios/HockeyAppPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ @implementation HockeyAppPlugin
#pragma mark Initialization

- (void)pluginInitialize {
NSString * hockeyAppKey = @"__HOCKEY_APP_KEY__";
NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];
NSString * hockeyAppKey = [infoPlist objectForKey:@"HockeyAppApiKey"];

if( hockeyAppKey!=nil && [hockeyAppKey isEqualToString:@""]==NO && [hockeyAppKey rangeOfString:@"HOCKEY_APP_KEY"].location == NSNotFound ){

// initialize before HockeySDK, so the delegate can access the file logger
Expand Down
Binary file removed src/ios/HockeySDK.embeddedframework/.DS_Store
Binary file not shown.
Binary file not shown.
Loading