diff --git a/.gitignore b/.gitignore index 0a9e55c..4a07bae 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,10 @@ Pods */*/bin/ */*/gen/ */*/build/ + +# Web +.idea + +# Development +node_modules +bower_components diff --git a/Hybridge.podspec b/Hybridge.podspec new file mode 100644 index 0000000..990a4a7 --- /dev/null +++ b/Hybridge.podspec @@ -0,0 +1,26 @@ +Pod::Spec.new do |s| + s.name = "Hybridge" + s.version = "1.2.0" + s.summary = "Yet another javascript / mobile native simple bridge for hybrid apps, back and forth..." + + s.description = <<-DESC + When developing hybrid apps surely you'll need to access different native features and resources. + Out there are plenty of bridge solutions. Hybridge tries to make easy communication and data + exchanging between native (iOS & Android) and Javascript worlds, avoiding too much overhead. + DESC + s.homepage = "https://github.com/telefonicaid/tdigital-hybridge" + + s.license = { :type => "Affero GNU GPL v3", :file => "LICENSE.txt" } + + s.authors = { 'David Garcia' => 'davidgarsan@gmail.com', 'Guillermo Gonzalez' => 'gonzalezreal@icloud.com' } + + s.platform = :ios + s.ios.deployment_target = "6.0" + s.source = { :git => "https://github.com/telefonicaid/tdigital-hybridge.git", :tag => "1.2.0" } + + s.source_files = "ios/Hybridge/Hybridge/*.{h,m}" + s.private_header_files = "ios/Hybridge/Hybridge/HYBURLProtocol.h", "ios/Hybridge/Hybridge/NSString+Hybridge.h" + + s.frameworks = "Foundation", "UIKit" + s.requires_arc = true +end diff --git a/README.md b/README.md index 0928c8f..7ad4cad 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ Yet another javascript / mobile native simple bridge for hybrid apps, back and f ## Index 1. [Why?](#why) - 1. [Getting Started](#start) - * [Dependencies](#dependencies) - * [Javascript](#dependencies_javascript) + 1. [Installation](#installation) + * [Javascript](#installation_javascript) + * [Android](#installation_android) + * [iOS](#installation_ios) 1. [Usage](#usage) * [Javascript](#usage_javascript) * [Android](#usage_android) @@ -31,13 +32,40 @@ Hybridge tries to make easy communication and data exchanging between native (iO **[[⬆]](#index)** -## Getting Started -Firstly, get the code by downloading the zip or cloning the project into your local. +## Installation +Hybridge follows [semantic versioning](http://semver.org/). In the `boilerplate` directory you can find examples of how to get running in the different platforms. -### Dependencies -#### Javascript -Hybridge works in an AMD fashion, so you'll need [RequireJS](http://requirejs.org) for the loading. -You'll also need [JQuery](http://jquery.com) (version 1.5 or newer) for the Javascript part since [Deferred](http://api.jquery.com/category/deferred-object) object is used intensively. +### Javascript + +Since v1.2.0, `hybridge` is available in [bower](http://bower.io/). Bower will install `hybridge` itself and all its dependencies. +```sh +bower install --save hybridge +``` + +Add it to your HTML +```html + +``` + +You can manually download the javascript [js/hybridge.js](js/hybridge.js) and use the traditional way. + +Hybridge works in both an AMD/Vanilla javascript fashion. For vanilla javascript, it's available in `window.Hybridge` variable. +You'll also need [JQuery](http://jquery.com) (version 1.8.3 or newer) for the Javascript part since [Deferred](http://api.jquery.com/category/deferred-object) object is used intensively. + + +### Android + +You can build your own Hybridge, but you can start with the latest version included at [hybridge.jar](boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.2.0.jar) in the boilerplate code. + +### iOS + +Add the following to your `Podfile` and run `$ pod install`. + +``` ruby +pod 'Hybridge' +``` + +If you don't have CocoaPods installed or integrated into your project, you can learn how to do so [here](http://cocoapods.org). **[[⬆]](#index)** @@ -57,13 +85,12 @@ Load `hybridge.js` as a module in your AMD code. Simplest setup: require.config({ baseUrl: 'js/lib', paths: { - jquery: 'jquery', - hybridge: 'hybridge' + jquery: 'bower_components/jquery/dist/jquery', + hybridge: 'bower_components/hybridge/js/hybridge' } }); - requirejs(['hybridge'], - function (Hybridge) { + require(['hybridge'], function (Hybridge) { Hybridge.init({ 'environment' : 'ios' } @@ -116,6 +143,7 @@ public class DownloadTask extends AsyncTask { private JsPromptResult result; private Context context; + private HybridgeBroadcaster hybridge; public DownloadTask(Context context) { this.context = context; @@ -125,6 +153,7 @@ public class DownloadTask extends AsyncTask { protected JSONObject doInBackground(Object... params) { JSONObject json = (JSONObject) params[0]; result = (JsPromptResult) params[1]; + hybridge = (HybridgeBroadcaster) params[2]; // Process download ... return json; @@ -139,21 +168,21 @@ webView.setWebViewClient(new HybridgeWebViewClient(JsActionImpl.values())); webView.setWebChromeClient(new HybridgeWebChromeClient(JsActionImpl.values())); ``` -* Implement `Observable` in your WebView and subscribe it in order to notificate Javascript the events received from `HybridgeBroadcaster`: +* Implement `Observable` in your WebView fragment and subscribe it in order to notificate Javascript the events received from `HybridgeBroadcaster`: ```java -HybridgeBroadcaster.getInstance().addObserver(this); +HybridgeBroadcaster.getInstance(mWebView).addObserver(this); ... @Override public void update(Observable observable, Object data) { JSONObject json = (JSONObject) data; if (json.has(HybridgeConst.EVENT_NAME)) { try { - HybridgeBroadcaster.getInstance().fireJavascriptEvent(mWebView, (Event) json.get(HybridgeConst.EVENT_NAME), json); + HybridgeBroadcaster.getInstance(mWebView).fireJavascriptEvent(mWebView, (Event) json.get(HybridgeConst.EVENT_NAME), json); } catch (JSONException e) { Log.e(mTag, "Problem with JSON object " + e.getMessage()); } } else { - HybridgeBroadcaster.getInstance().fireMessage(mWebView, json); + HybridgeBroadcaster.getInstance(mWebView).fireMessage(mWebView, json); } } ``` @@ -161,29 +190,57 @@ public void update(Observable observable, Object data) { **[[⬆]](#index)** ### iOS -* Compile the sources and copy the Hybridge static lib in your project `HYBHybridge.h` and `libHybridge.a`. -* Import `HYBHybridge.h` in your *UIWebView* controller. -* Bind the Hybridge singleton: -```objective-c -_hybridge = [HYBHybridge sharedInstance] +#### Creating a Web View Controller +Hybridge provides `HYBWebViewController`, a convenience view controller that hosts both a web view and a bridge object to communicate with it. Users are encouraged to subclass `HYBWebViewController` and specify any supported bridge actions. + +```objc +#import + +@interface MyWebViewController : HYBWebViewController +@end ``` -* Implements your native `actions` in *blocks* with the handler `HybridgeHandlerBlock_t`: - -```objective-c -HybridgeHandlerBlock_t downloadHandler = ^(NSURLProtocol *url, NSString *data, NSHTTPURLResponse *response) { - NSDictionary *params = [_parser objectWithString:data]; - // Handle download with data from Javascript request - ... -}; + +```objc +... +- (NSArray *)bridgeActions:(HYBBridge *)bridge { + return @[@"some_action", @"some_other_action"]; +} ``` -* You'll parse the JSON `data` sent from Javascript as seen in the previous code snippet. -* Finally, subscribe each of your `actions` to the Hybridge by binding to the name you'll use to invoke it from Javascript. -```objective-c -[_hybridge subscribeAction:@"download" withHandler:downloadHandler]; +There are two different ways to handle bridge actions: + +1. Override `-bridgeDidReceiveAction:data:` + +```objc +- (NSDictionary *)bridgeDidReceiveAction:(NSString *)action data:(NSDictionary *)data { + if ([action isEqualToString:@"some_action"]) { + // Handle 'some_action' + } else if ([action isEqualToString:@"some_other_action"]) { + // Handle 'some_other_action' + } + + // Return a JSON dictionary or `nil` + return nil; +} ``` +2. Implement a method with a special signature for each supported action. The bridge will look for methods with the signature `- (NSDictionary *)handleWithData:(NSDictionary *)data` + +```objc +- (NSDictionary *)handleSomeActionWithData:(NSDictionary *)data { + // Handle 'some_action' + return @{ @"foo": @"bar" }; +} + +- (NSDictionary *)handleSomeOtherActionWithData:(NSDictionary *)data { + // Handle 'some_other_action' + return nil; +} +``` + +Note the **CamelCase** in the method signature. If your action is named `some_action`, this becomes `SomeAction` in the method signature. + **[[⬆]](#index)** ### Boilerplate @@ -206,15 +263,16 @@ You can communicate to Javascript from Android/iOS by triggering any of the defi * **message**: Send arbitrary data when required. ### Android -Use *HybridgeBroadcaster* singleton to trigger events in Javascript: +Use *HybridgeBroadcaster* instance to trigger events in Javascript: ```java -HybridgeBroadcaster.getInstance().fireJavascriptEvent(webView, Event.READY, jsonData); +HybridgeBroadcaster.getInstance(mWebView).fireJavascriptEvent(webView, Event.READY, jsonData); ``` ### iOS -Use *Hybridge* singleton to trigger events in Javascript: -```objective-c -[_hybridge fireEventInWebView:kHybridgeEventReady data:@"{foo : \"data\"}" web:self.webview] +Hybridge provides an `UIWebView` category that sports a convenience method to trigger events on the Javascript side. + +```objc +[self.webView hyb_fireEvent:HYBEventMessage data:@{ @"foo": @"bar" }]; ``` ### Javascript @@ -264,6 +322,11 @@ let's enumerate the available methods and properties from the Hybridge Javascrip Provides the way to communicate from Javascript to native side. An `action` parameter is required in order to execute an implemented native task. Returns a [JQuery](http://jquery.com) [Promise](http://api.jquery.com/Types/#Promise) containing data returned from native or custom error. You can add a second function parameter `fallback` in case something goes wrong and you want to supply aditional user feedback as well as update your UI. +* **ready(callback:Function)** + Function that executes the callback function once Hybridge has become enabled. If Hybridge was enabled at calling time, + the callback is executed inmediatly. The main difference with `addListener('ready', handler)` event subscription + is that the event handler never becomes executed when the subscription happens and Hybridge was enabled + ### Properties * **errors** Container object of customs errors returned by the Hybridge: diff --git a/android/Hybridge/AndroidManifest.xml b/android/Hybridge/AndroidManifest.xml index 33dc466..7bd9bb6 100644 --- a/android/Hybridge/AndroidManifest.xml +++ b/android/Hybridge/AndroidManifest.xml @@ -1,9 +1,9 @@ + android:versionCode="120" + android:versionName="1.2.0" > - \ No newline at end of file + diff --git a/android/Hybridge/src/com/pdi/hybridge/HybridgeBroadcaster.java b/android/Hybridge/src/com/pdi/hybridge/HybridgeBroadcaster.java index 85482cd..34bf6cc 100644 --- a/android/Hybridge/src/com/pdi/hybridge/HybridgeBroadcaster.java +++ b/android/Hybridge/src/com/pdi/hybridge/HybridgeBroadcaster.java @@ -6,110 +6,92 @@ package com.pdi.hybridge; -import java.util.HashMap; -import java.util.Observable; -import java.util.Observer; - -import org.json.JSONArray; -import org.json.JSONObject; - -import android.annotation.SuppressLint; -import android.os.AsyncTask; import android.util.Log; +import android.util.SparseArray; import android.webkit.WebView; import android.webkit.WebView.HitTestResult; import com.pdi.hybridge.HybridgeConst.Event; -public class HybridgeBroadcaster extends Observable { +import org.json.JSONArray; +import org.json.JSONObject; - private static HybridgeBroadcaster instance; +import java.lang.ref.WeakReference; +import java.util.Observable; +import java.util.Observer; - private boolean isInitialized = false; +public class HybridgeBroadcaster extends Observable { - private final String TAG = "HybridgeBroadcaster"; + private boolean mIsInitialized = false; - private StringBuffer jsBuffer; - - private HashMap> currents; + private final String TAG = "HybridgeBroadcaster"; - @SuppressLint("UseSparseArrays") - public HybridgeBroadcaster() { - currents = new HashMap>(); - jsBuffer = new StringBuffer(""); - } + private StringBuffer mJsBuffer; - public static HybridgeBroadcaster getInstance() { - if (instance == null) { - instance = new HybridgeBroadcaster(); - } - return instance; + private HybridgeBroadcaster() { + mJsBuffer = new StringBuffer(""); } public void initJs(WebView view, JSONArray actions, JSONArray events) { - runJsInWebView(view, "window.HybridgeGlobal || setTimeout(function () {" + - "window.HybridgeGlobal = {" + - " isReady : true" + - ", version : " + HybridgeConst.VERSION + - ", actions : " + actions.toString() + - ", events : " + events.toString() + - "};" + - "window.$ && $('#hybridgeTrigger').toggleClass('switch');" + - "},0)" - ); - isInitialized = true; + runJsInWebView(view, "window.HybridgeGlobal || setTimeout(function () {" + + "window.HybridgeGlobal = {" + " isReady : true" + ", version : " + + HybridgeConst.VERSION + ", versionMinor : " + HybridgeConst.VERSION_MINOR + + ", actions : " + actions.toString() + ", events : " + events.toString() + "};" + + "(window.document.getElementById('hybridgeTrigger') || {}).className = 'switch';" + + "},0)"); + mIsInitialized = true; } public void firePause(WebView view) { - HybridgeConst.Event event = HybridgeConst.Event.PAUSE; + final HybridgeConst.Event event = HybridgeConst.Event.PAUSE; notifyObservers(event); fireJavascriptEvent(view, event, null); } public void fireResume(WebView view) { - HybridgeConst.Event event = HybridgeConst.Event.RESUME; + final HybridgeConst.Event event = HybridgeConst.Event.RESUME; notifyObservers(event); fireJavascriptEvent(view, event, null); } - public void fireMessage (WebView view, JSONObject data) { - HybridgeConst.Event event = HybridgeConst.Event.MESSAGE; + public void fireMessage(WebView view, JSONObject data) { + final HybridgeConst.Event event = HybridgeConst.Event.MESSAGE; notifyObservers(event); fireJavascriptEvent(view, event, data); } public void fireReady(WebView view, JSONObject data) { - HybridgeConst.Event event = HybridgeConst.Event.READY; + final HybridgeConst.Event event = HybridgeConst.Event.READY; notifyObservers(event); fireJavascriptEvent(view, event, data); } public void fireJavascriptEvent(final WebView view, final Event event, final JSONObject data) { - if (isInitialized) { - view.post( - new Runnable() { - @Override - public void run() { - WebView.HitTestResult hitTestResult = ((WebView)view).getHitTestResult(); - String prejs = ""; - String json = data != null ? data.toString() : "{}"; - StringBuffer js = new StringBuffer("HybridgeGlobal.fireEvent(\""); - js.append(event.getJsName()).append("\",").append(json).append(");"); - - if (hitTestResult == null || hitTestResult.getType() != HitTestResult.EDIT_TEXT_TYPE) { - if(jsBuffer.length() != 0) { - prejs = jsBuffer.append(js.toString()).toString(); - runJsInWebView(view, prejs); - jsBuffer = new StringBuffer(""); - } else { - runJsInWebView(view, js.toString()); - } + if (mIsInitialized) { + view.post(new Runnable() { + @Override + public void run() { + final WebView.HitTestResult hitTestResult = view.getHitTestResult(); + String prejs = ""; + final String json = data != null ? data.toString() : "{}"; + final StringBuffer js = new StringBuffer("HybridgeGlobal.fireEvent(\""); + js.append(event.getJsName()).append("\",").append(json).append(");"); + + if (hitTestResult == null + || hitTestResult.getType() != HitTestResult.EDIT_TEXT_TYPE) { + if (mJsBuffer.length() != 0) { + prejs = mJsBuffer.append(js.toString()).toString(); + runJsInWebView(view, prejs); + mJsBuffer = new StringBuffer(""); } else { - Log.d(TAG, "Defer javascript message, user is entering text"); - jsBuffer.append(js.toString()); + runJsInWebView(view, js.toString()); } + } else { + Log.d(TAG, "Defer javascript message, user is entering text"); + mJsBuffer.append(js.toString()); } - }); + } + }); } } @@ -123,30 +105,40 @@ public void updateState(JSONObject data) { Log.d(TAG, data.toString()); } - @SuppressWarnings("unchecked") @Override public void addObserver(Observer observer) { super.addObserver(observer); - Class clazz = observer.getClass().getSuperclass(); - if (clazz != null && clazz == android.os.AsyncTask.class) { - int hashCode = observer.hashCode(); - AsyncTask current = currents.get(hashCode); - if (current != null) { - if (current.cancel(true)) { - currents.remove(hashCode); - } - } - currents.put(hashCode, (AsyncTask) observer); - } } @Override public void deleteObserver(Observer observer) { super.deleteObserver(observer); - Class clazz = observer.getClass().getSuperclass(); - if (clazz != null && clazz == android.os.AsyncTask.class) { - int hashCode = observer.hashCode(); - currents.remove(hashCode); - } + } + + /* + * Factory methods for HybridgeBroadcaster instantiation + */ + + /** + * Keeps track of the current HybridgeBroadcaster instances in the app based in each WebView + * hash + */ + private static SparseArray> sClients; + static { + sClients = new SparseArray>(); + } + + public static synchronized HybridgeBroadcaster getInstance(WebView client) { + final int hash = client.hashCode(); + WeakReference instance = sClients.get(hash); + if (instance == null || instance.get() == null) { + instance = new WeakReference(new HybridgeBroadcaster()); + sClients.put(hash, instance); + } + return instance.get(); + } + + public static void destroy(WebView client) { + sClients.remove(client.hashCode()); } } diff --git a/android/Hybridge/src/com/pdi/hybridge/HybridgeConst.java b/android/Hybridge/src/com/pdi/hybridge/HybridgeConst.java index d6ba668..7f19a51 100644 --- a/android/Hybridge/src/com/pdi/hybridge/HybridgeConst.java +++ b/android/Hybridge/src/com/pdi/hybridge/HybridgeConst.java @@ -9,14 +9,12 @@ public class HybridgeConst { public static final int VERSION = 1; + public static final int VERSION_MINOR = 2; public static final String EVENT_NAME = "event"; public enum Event { - PAUSE("pause"), - RESUME("resume"), - MESSAGE("message"), - READY("ready"); + PAUSE("pause"), RESUME("resume"), MESSAGE("message"), READY("ready"); private String jsName; diff --git a/android/Hybridge/src/com/pdi/hybridge/HybridgeWebChromeClient.java b/android/Hybridge/src/com/pdi/hybridge/HybridgeWebChromeClient.java index 32bcc4e..c6850c6 100644 --- a/android/Hybridge/src/com/pdi/hybridge/HybridgeWebChromeClient.java +++ b/android/Hybridge/src/com/pdi/hybridge/HybridgeWebChromeClient.java @@ -6,12 +6,6 @@ package com.pdi.hybridge; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; - -import org.json.JSONException; -import org.json.JSONObject; - import android.annotation.SuppressLint; import android.app.Activity; import android.os.AsyncTask; @@ -20,32 +14,40 @@ import android.webkit.WebChromeClient; import android.webkit.WebView; +import org.json.JSONException; +import org.json.JSONObject; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; + public class HybridgeWebChromeClient extends WebChromeClient { protected String mTag = "HybridgeWebChromeClient"; @SuppressWarnings("rawtypes") - protected HashMap actions; + protected HashMap mActions; @SuppressWarnings("rawtypes") @SuppressLint("DefaultLocale") - public HybridgeWebChromeClient(JsAction[] actions) { - this.actions = new HashMap(actions.length); - for (JsAction action : actions) { - this.actions.put(action.toString().toLowerCase(), action.getTask()); + public HybridgeWebChromeClient(JsAction[] actions) { + mActions = new HashMap(actions.length); + for (final JsAction action : actions) { + mActions.put(action.toString().toLowerCase(), action.getTask()); } } @Override - public final boolean onJsPrompt(WebView view, String url, String msg, String defValue, JsPromptResult result) { - String action = msg; + public final boolean onJsPrompt(WebView view, String url, String msg, String defValue, + JsPromptResult result) { + final String action = msg; JSONObject json = null; Log.v(mTag, "Hybridge action: " + action); try { json = new JSONObject(defValue); Log.v(mTag, "JSON parsed (Action " + action + ") : " + json.toString()); - executeJSONTask(action, json, result, (Activity) view.getContext()); - } catch (JSONException e) { + executeJSONTask(action, json, result, HybridgeBroadcaster.getInstance(view), + (Activity) view.getContext()); + } catch (final JSONException e) { result.cancel(); Log.e(mTag, e.getMessage()); } @@ -53,29 +55,33 @@ public final boolean onJsPrompt(WebView view, String url, String msg, String def } @SuppressLint("DefaultLocale") - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void executeJSONTask(String action, JSONObject json, JsPromptResult result, Activity activity) { - Class clazz = this.actions.get(action); - if (clazz != null) { + @SuppressWarnings({ + "unchecked", "rawtypes" + }) + private void executeJSONTask(String action, JSONObject json, JsPromptResult result, + HybridgeBroadcaster hybridge, Activity activity) { + final Class clazz = mActions.get(action); + if (clazz != null && hybridge != null) { AsyncTask task = null; try { - task = (AsyncTask) - clazz.getDeclaredConstructor - ( new Class[] { android.app.Activity.class } ) - .newInstance(activity); - } catch (InstantiationException e) { + task = + (AsyncTask) clazz.getDeclaredConstructor( + new Class[] { + android.app.Activity.class + }).newInstance(activity); + } catch (final InstantiationException e) { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { e.printStackTrace(); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { e.printStackTrace(); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { e.printStackTrace(); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { e.printStackTrace(); } Log.v(mTag, "Execute action " + action); - task.execute(json, result); + task.execute(json, result, hybridge); } else { result.confirm(json.toString()); Log.d(mTag, "Hybridge action not implemented: " + action); diff --git a/android/Hybridge/src/com/pdi/hybridge/HybridgeWebViewClient.java b/android/Hybridge/src/com/pdi/hybridge/HybridgeWebViewClient.java index c8d4afe..786a375 100644 --- a/android/Hybridge/src/com/pdi/hybridge/HybridgeWebViewClient.java +++ b/android/Hybridge/src/com/pdi/hybridge/HybridgeWebViewClient.java @@ -6,44 +6,39 @@ package com.pdi.hybridge; -import org.json.JSONArray; - import android.annotation.SuppressLint; -import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.pdi.hybridge.HybridgeConst.Event; +import org.json.JSONArray; + public class HybridgeWebViewClient extends WebViewClient { - protected JSONArray actions; - protected JSONArray events; - protected HybridgeBroadcaster broadcast; + protected JSONArray mActions; + protected JSONArray mEvents; @SuppressLint("DefaultLocale") - public HybridgeWebViewClient(JsAction[] actions) { - this.actions = new JSONArray(); - for (JsAction action : actions) { - this.actions.put(action.toString().toLowerCase()); + public HybridgeWebViewClient(JsAction[] actions) { + mActions = new JSONArray(); + for (final JsAction action : actions) { + this.mActions.put(action.toString().toLowerCase()); } - this.events = new JSONArray(); - Event[] events = HybridgeConst.Event.values(); - for (Event event : events) { - this.events.put(event.getJsName()); + mEvents = new JSONArray(); + final Event[] events = HybridgeConst.Event.values(); + for (final Event event : events) { + this.mEvents.put(event.getJsName()); } - this.broadcast = HybridgeBroadcaster.getInstance(); } @Override - public WebResourceResponse shouldInterceptRequest(WebView view, String url) { - return super.shouldInterceptRequest(view, url); - } - - @Override public void onPageFinished(WebView view, String url) { - this.broadcast.initJs(view, actions, events); + super.onPageFinished(view, url); + final HybridgeBroadcaster hybridge = HybridgeBroadcaster.getInstance(view); + if (hybridge != null) { + hybridge.initJs(view, mActions, mEvents); + } } - } diff --git a/android/Hybridge/version.properties b/android/Hybridge/version.properties index d5c3943..83cd022 100644 --- a/android/Hybridge/version.properties +++ b/android/Hybridge/version.properties @@ -2,5 +2,5 @@ #Version = ${build.platform.number}.${build.major.number}.${build.minor.number} build.revision.number=1 -build.major.number=0 +build.major.number=2 build.minor.number=0 diff --git a/boilerplate/android/HybridgeBoilerplate/.classpath b/boilerplate/android/HybridgeBoilerplate/.classpath index 6aed2eb..7bc01d9 100644 --- a/boilerplate/android/HybridgeBoilerplate/.classpath +++ b/boilerplate/android/HybridgeBoilerplate/.classpath @@ -4,5 +4,6 @@ + diff --git a/boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.1.0.jar b/boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.1.0.jar deleted file mode 100644 index 81019a5..0000000 Binary files a/boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.1.0.jar and /dev/null differ diff --git a/boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.2.0.jar b/boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.2.0.jar new file mode 100644 index 0000000..b4e5e77 Binary files /dev/null and b/boilerplate/android/HybridgeBoilerplate/libs/hybridge-1.2.0.jar differ diff --git a/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/MainActivity.java b/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/MainActivity.java index 0077840..0b88d5d 100644 --- a/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/MainActivity.java +++ b/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/MainActivity.java @@ -6,12 +6,6 @@ package com.pdi.hybridge.boilerplate; -import java.util.Observable; -import java.util.Observer; - -import org.json.JSONException; -import org.json.JSONObject; - import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; @@ -21,47 +15,74 @@ import com.pdi.hybridge.HybridgeBroadcaster; import com.pdi.hybridge.HybridgeConst; +import com.pdi.hybridge.HybridgeConst.Event; import com.pdi.hybridge.HybridgeWebChromeClient; import com.pdi.hybridge.HybridgeWebViewClient; -import com.pdi.hybridge.HybridgeConst.Event; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Observable; +import java.util.Observer; public class MainActivity extends Activity implements Observer { - + private String mTag = "MainActivity"; private WebView mWebView; - + private HybridgeBroadcaster mHybridge; + // String keys for JSON data user in Hybridge communication public static final String JSON_KEY_INIT = "initialized"; - + @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - HybridgeBroadcaster.getInstance().addObserver(this); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(webViewClient); mWebView.setWebChromeClient(webChromeClient); + mHybridge = HybridgeBroadcaster.getInstance(mWebView); // Set the URL of your web app - mWebView.loadUrl("http://localhost/hybridge.html"); + mWebView.loadUrl("http://192.168.1.40/hybridge.html"); } - private final HybridgeWebViewClient webViewClient = new HybridgeWebViewClient(JsActionImpl.values()); + private final HybridgeWebViewClient webViewClient = new HybridgeWebViewClient( + JsActionImpl.values()); + + private final WebChromeClient webChromeClient = new HybridgeWebChromeClient( + JsActionImpl.values()); - private final WebChromeClient webChromeClient = new HybridgeWebChromeClient(JsActionImpl.values()); - @Override public void update(Observable observable, Object data) { - JSONObject json = (JSONObject) data; + final JSONObject json = (JSONObject) data; if (json.has(HybridgeConst.EVENT_NAME)) { try { - HybridgeBroadcaster.getInstance().fireJavascriptEvent(mWebView, (Event) json.get(HybridgeConst.EVENT_NAME), json); - } catch (JSONException e) { + mHybridge.fireJavascriptEvent(mWebView, (Event) json.get(HybridgeConst.EVENT_NAME), + json); + } catch (final JSONException e) { Log.e(mTag, "Problem with JSON object " + e.getMessage()); } } else { - HybridgeBroadcaster.getInstance().fireMessage(mWebView, json); + mHybridge.fireMessage(mWebView, json); } } + + /** + * Callback invoke once the fragment is created. + * + * @see android.app.Fragment#onResume() + */ + @Override + public void onResume() { + mHybridge.addObserver(this); + super.onResume(); + } + + @Override + public void onPause() { + mHybridge.deleteObserver(this); + super.onPause(); + } } diff --git a/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/action/InitTask.java b/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/action/InitTask.java index fb6cd85..a945a88 100644 --- a/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/action/InitTask.java +++ b/boilerplate/android/HybridgeBoilerplate/src/com/pdi/hybridge/boilerplate/action/InitTask.java @@ -6,9 +6,6 @@ package com.pdi.hybridge.boilerplate.action; -import org.json.JSONException; -import org.json.JSONObject; - import android.app.Activity; import android.content.Context; import android.os.AsyncTask; @@ -19,27 +16,32 @@ import com.pdi.hybridge.HybridgeConst; import com.pdi.hybridge.boilerplate.MainActivity; +import org.json.JSONException; +import org.json.JSONObject; + public class InitTask extends AsyncTask { private final String mTag = "InitTask"; - private JsPromptResult result; - private Context context; + private JsPromptResult mResult; + private Context mContext; + private HybridgeBroadcaster mHybridge; public InitTask(Activity activity) { - this.context = activity.getApplicationContext(); + mContext = activity.getApplicationContext(); } @Override protected JSONObject doInBackground(Object... params) { - JSONObject json = (JSONObject) params[0]; - result = (JsPromptResult) params[1]; + final JSONObject json = (JSONObject) params[0]; + mResult = (JsPromptResult) params[1]; + mHybridge = (HybridgeBroadcaster) params[2]; try { if (json.has(MainActivity.JSON_KEY_INIT)) { json.put(HybridgeConst.EVENT_NAME, HybridgeConst.Event.READY); - HybridgeBroadcaster.getInstance().updateState(json); + mHybridge.updateState(json); } - } catch (JSONException e) { + } catch (final JSONException e) { Log.e(mTag, "Download: Problem with JSON object " + e.getMessage()); } @@ -53,7 +55,7 @@ protected void onPreExecute() { @Override protected void onPostExecute(JSONObject json) { - result.confirm(json.toString()); + mResult.confirm(json.toString()); } -} \ No newline at end of file +} diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate.xcodeproj/project.pbxproj b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate.xcodeproj/project.pbxproj deleted file mode 100644 index 5e10203..0000000 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate.xcodeproj/project.pbxproj +++ /dev/null @@ -1,533 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - E44681CA1879895800D18DF3 /* libHybridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C80925182C0F40002BF73C /* libHybridge.a */; }; - E47A5FAD184764270041F290 /* libHybridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C80925182C0F40002BF73C /* libHybridge.a */; }; - E4C808D6182A7BCE002BF73C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C808D5182A7BCE002BF73C /* Foundation.framework */; }; - E4C808D8182A7BCE002BF73C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C808D7182A7BCE002BF73C /* CoreGraphics.framework */; }; - E4C808DA182A7BCE002BF73C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C808D9182A7BCE002BF73C /* UIKit.framework */; }; - E4C808E2182A7BCE002BF73C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E4C808E1182A7BCE002BF73C /* main.m */; }; - E4C808E6182A7BCE002BF73C /* HybridgeAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E4C808E5182A7BCE002BF73C /* HybridgeAppDelegate.m */; }; - E4C808EF182A7BCE002BF73C /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C808EE182A7BCE002BF73C /* XCTest.framework */; }; - E4C808F0182A7BCE002BF73C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C808D5182A7BCE002BF73C /* Foundation.framework */; }; - E4C808F1182A7BCE002BF73C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C808D9182A7BCE002BF73C /* UIKit.framework */; }; - E4C808F9182A7BCE002BF73C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E4C808F7182A7BCE002BF73C /* InfoPlist.strings */; }; - E4C808FB182A7BCE002BF73C /* HybridgeBoilerplateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E4C808FA182A7BCE002BF73C /* HybridgeBoilerplateTests.m */; }; - E4C80909182A7E52002BF73C /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E4C80908182A7E52002BF73C /* WebViewController.m */; }; - E4C80923182C0DE2002BF73C /* HybridgeBoilerplate-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = E4C808DD182A7BCE002BF73C /* HybridgeBoilerplate-Info.plist */; }; - E4C80924182C0DE2002BF73C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E4C808DE182A7BCE002BF73C /* InfoPlist.strings */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - E4C808F2182A7BCE002BF73C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E4C808CA182A7BCE002BF73C /* Project object */; - proxyType = 1; - remoteGlobalIDString = E4C808D1182A7BCE002BF73C; - remoteInfo = HybridgeBoilerplate; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - E47A5FAC184762940041F290 /* HYBHybridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HYBHybridge.h; sourceTree = ""; }; - E4C808D2182A7BCE002BF73C /* HybridgeBoilerplate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HybridgeBoilerplate.app; sourceTree = BUILT_PRODUCTS_DIR; }; - E4C808D5182A7BCE002BF73C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - E4C808D7182A7BCE002BF73C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - E4C808D9182A7BCE002BF73C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - E4C808DD182A7BCE002BF73C /* HybridgeBoilerplate-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HybridgeBoilerplate-Info.plist"; sourceTree = ""; }; - E4C808DF182A7BCE002BF73C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - E4C808E1182A7BCE002BF73C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - E4C808E3182A7BCE002BF73C /* HybridgeBoilerplate-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HybridgeBoilerplate-Prefix.pch"; sourceTree = ""; }; - E4C808E4182A7BCE002BF73C /* HybridgeAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HybridgeAppDelegate.h; sourceTree = ""; }; - E4C808E5182A7BCE002BF73C /* HybridgeAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HybridgeAppDelegate.m; sourceTree = ""; }; - E4C808ED182A7BCE002BF73C /* HybridgeBoilerplateTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HybridgeBoilerplateTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - E4C808EE182A7BCE002BF73C /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; - E4C808F6182A7BCE002BF73C /* HybridgeBoilerplateTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HybridgeBoilerplateTests-Info.plist"; sourceTree = ""; }; - E4C808F8182A7BCE002BF73C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - E4C808FA182A7BCE002BF73C /* HybridgeBoilerplateTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HybridgeBoilerplateTests.m; sourceTree = ""; }; - E4C80907182A7E52002BF73C /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = ""; }; - E4C80908182A7E52002BF73C /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = ""; }; - E4C80925182C0F40002BF73C /* libHybridge.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libHybridge.a; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - E4C808CF182A7BCE002BF73C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - E47A5FAD184764270041F290 /* libHybridge.a in Frameworks */, - E4C808D8182A7BCE002BF73C /* CoreGraphics.framework in Frameworks */, - E4C808DA182A7BCE002BF73C /* UIKit.framework in Frameworks */, - E4C808D6182A7BCE002BF73C /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - E4C808EA182A7BCE002BF73C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - E4C808EF182A7BCE002BF73C /* XCTest.framework in Frameworks */, - E4C808F1182A7BCE002BF73C /* UIKit.framework in Frameworks */, - E4C808F0182A7BCE002BF73C /* Foundation.framework in Frameworks */, - E44681CA1879895800D18DF3 /* libHybridge.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - E4C808C9182A7BCE002BF73C = { - isa = PBXGroup; - children = ( - E4C808DB182A7BCE002BF73C /* HybridgeBoilerplate */, - E4C808F4182A7BCE002BF73C /* HybridgeBoilerplateTests */, - E4C808D4182A7BCE002BF73C /* Frameworks */, - E4C808D3182A7BCE002BF73C /* Products */, - ); - sourceTree = ""; - }; - E4C808D3182A7BCE002BF73C /* Products */ = { - isa = PBXGroup; - children = ( - E4C808D2182A7BCE002BF73C /* HybridgeBoilerplate.app */, - E4C808ED182A7BCE002BF73C /* HybridgeBoilerplateTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - E4C808D4182A7BCE002BF73C /* Frameworks */ = { - isa = PBXGroup; - children = ( - E4C808D5182A7BCE002BF73C /* Foundation.framework */, - E4C808D7182A7BCE002BF73C /* CoreGraphics.framework */, - E4C808D9182A7BCE002BF73C /* UIKit.framework */, - E4C808EE182A7BCE002BF73C /* XCTest.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - E4C808DB182A7BCE002BF73C /* HybridgeBoilerplate */ = { - isa = PBXGroup; - children = ( - E4C80911182A8FD8002BF73C /* include */, - E4C80910182A8FCE002BF73C /* lib */, - E4C80906182A7E14002BF73C /* controllers */, - E4C808E4182A7BCE002BF73C /* HybridgeAppDelegate.h */, - E4C808E5182A7BCE002BF73C /* HybridgeAppDelegate.m */, - E4C808DC182A7BCE002BF73C /* Supporting Files */, - ); - path = HybridgeBoilerplate; - sourceTree = ""; - }; - E4C808DC182A7BCE002BF73C /* Supporting Files */ = { - isa = PBXGroup; - children = ( - E4C808DD182A7BCE002BF73C /* HybridgeBoilerplate-Info.plist */, - E4C808DE182A7BCE002BF73C /* InfoPlist.strings */, - E4C808E1182A7BCE002BF73C /* main.m */, - E4C808E3182A7BCE002BF73C /* HybridgeBoilerplate-Prefix.pch */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - E4C808F4182A7BCE002BF73C /* HybridgeBoilerplateTests */ = { - isa = PBXGroup; - children = ( - E4C808FA182A7BCE002BF73C /* HybridgeBoilerplateTests.m */, - E4C808F5182A7BCE002BF73C /* Supporting Files */, - ); - path = HybridgeBoilerplateTests; - sourceTree = ""; - }; - E4C808F5182A7BCE002BF73C /* Supporting Files */ = { - isa = PBXGroup; - children = ( - E4C808F6182A7BCE002BF73C /* HybridgeBoilerplateTests-Info.plist */, - E4C808F7182A7BCE002BF73C /* InfoPlist.strings */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - E4C80906182A7E14002BF73C /* controllers */ = { - isa = PBXGroup; - children = ( - E4C80907182A7E52002BF73C /* WebViewController.h */, - E4C80908182A7E52002BF73C /* WebViewController.m */, - ); - name = controllers; - sourceTree = ""; - }; - E4C80910182A8FCE002BF73C /* lib */ = { - isa = PBXGroup; - children = ( - E4C80925182C0F40002BF73C /* libHybridge.a */, - ); - name = lib; - sourceTree = ""; - }; - E4C80911182A8FD8002BF73C /* include */ = { - isa = PBXGroup; - children = ( - E4C80912182A8FE3002BF73C /* Hybridge */, - ); - name = include; - sourceTree = ""; - }; - E4C80912182A8FE3002BF73C /* Hybridge */ = { - isa = PBXGroup; - children = ( - E47A5FAC184762940041F290 /* HYBHybridge.h */, - ); - name = Hybridge; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - E4C808D1182A7BCE002BF73C /* HybridgeBoilerplate */ = { - isa = PBXNativeTarget; - buildConfigurationList = E4C808FE182A7BCE002BF73C /* Build configuration list for PBXNativeTarget "HybridgeBoilerplate" */; - buildPhases = ( - E4C808CE182A7BCE002BF73C /* Sources */, - E4C808CF182A7BCE002BF73C /* Frameworks */, - E4C808D0182A7BCE002BF73C /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = HybridgeBoilerplate; - productName = HybridgeBoilerplate; - productReference = E4C808D2182A7BCE002BF73C /* HybridgeBoilerplate.app */; - productType = "com.apple.product-type.application"; - }; - E4C808EC182A7BCE002BF73C /* HybridgeBoilerplateTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = E4C80901182A7BCE002BF73C /* Build configuration list for PBXNativeTarget "HybridgeBoilerplateTests" */; - buildPhases = ( - E4C808E9182A7BCE002BF73C /* Sources */, - E4C808EA182A7BCE002BF73C /* Frameworks */, - E4C808EB182A7BCE002BF73C /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - E4C808F3182A7BCE002BF73C /* PBXTargetDependency */, - ); - name = HybridgeBoilerplateTests; - productName = HybridgeBoilerplateTests; - productReference = E4C808ED182A7BCE002BF73C /* HybridgeBoilerplateTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - E4C808CA182A7BCE002BF73C /* Project object */ = { - isa = PBXProject; - attributes = { - CLASSPREFIX = Hybridge; - LastUpgradeCheck = 0500; - ORGANIZATIONNAME = tid.es; - TargetAttributes = { - E4C808EC182A7BCE002BF73C = { - TestTargetID = E4C808D1182A7BCE002BF73C; - }; - }; - }; - buildConfigurationList = E4C808CD182A7BCE002BF73C /* Build configuration list for PBXProject "HybridgeBoilerplate" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = E4C808C9182A7BCE002BF73C; - productRefGroup = E4C808D3182A7BCE002BF73C /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - E4C808D1182A7BCE002BF73C /* HybridgeBoilerplate */, - E4C808EC182A7BCE002BF73C /* HybridgeBoilerplateTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - E4C808D0182A7BCE002BF73C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - E4C80923182C0DE2002BF73C /* HybridgeBoilerplate-Info.plist in Resources */, - E4C80924182C0DE2002BF73C /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - E4C808EB182A7BCE002BF73C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - E4C808F9182A7BCE002BF73C /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - E4C808CE182A7BCE002BF73C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - E4C808E6182A7BCE002BF73C /* HybridgeAppDelegate.m in Sources */, - E4C80909182A7E52002BF73C /* WebViewController.m in Sources */, - E4C808E2182A7BCE002BF73C /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - E4C808E9182A7BCE002BF73C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - E4C808FB182A7BCE002BF73C /* HybridgeBoilerplateTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - E4C808F3182A7BCE002BF73C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E4C808D1182A7BCE002BF73C /* HybridgeBoilerplate */; - targetProxy = E4C808F2182A7BCE002BF73C /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - E4C808DE182A7BCE002BF73C /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - E4C808DF182A7BCE002BF73C /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; - E4C808F7182A7BCE002BF73C /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - E4C808F8182A7BCE002BF73C /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - E4C808FC182A7BCE002BF73C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - E4C808FD182A7BCE002BF73C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - E4C808FF182A7BCE002BF73C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch"; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - $SOURCE_ROOT/include, - ); - INFOPLIST_FILE = "HybridgeBoilerplate/HybridgeBoilerplate-Info.plist"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - "$(SRCROOT)/HybridgeBoilerplate", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - E4C80900182A7BCE002BF73C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch"; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - $SOURCE_ROOT/include, - ); - INFOPLIST_FILE = "HybridgeBoilerplate/HybridgeBoilerplate-Info.plist"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - "$(SRCROOT)/HybridgeBoilerplate", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; - }; - name = Release; - }; - E4C80902182A7BCE002BF73C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HybridgeBoilerplate.app/HybridgeBoilerplate"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - "$(DEVELOPER_FRAMEWORKS_DIR)", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = "HybridgeBoilerplateTests/HybridgeBoilerplateTests-Info.plist"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = xctest; - }; - name = Debug; - }; - E4C80903182A7BCE002BF73C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HybridgeBoilerplate.app/HybridgeBoilerplate"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - "$(DEVELOPER_FRAMEWORKS_DIR)", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch"; - INFOPLIST_FILE = "HybridgeBoilerplateTests/HybridgeBoilerplateTests-Info.plist"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = xctest; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - E4C808CD182A7BCE002BF73C /* Build configuration list for PBXProject "HybridgeBoilerplate" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - E4C808FC182A7BCE002BF73C /* Debug */, - E4C808FD182A7BCE002BF73C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - E4C808FE182A7BCE002BF73C /* Build configuration list for PBXNativeTarget "HybridgeBoilerplate" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - E4C808FF182A7BCE002BF73C /* Debug */, - E4C80900182A7BCE002BF73C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - E4C80901182A7BCE002BF73C /* Build configuration list for PBXNativeTarget "HybridgeBoilerplateTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - E4C80902182A7BCE002BF73C /* Debug */, - E4C80903182A7BCE002BF73C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = E4C808CA182A7BCE002BF73C /* Project object */; -} diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HYBHybridge.h b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HYBHybridge.h deleted file mode 100644 index 57cd0cd..0000000 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HYBHybridge.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Hybridge - * (c) Telefonica Digital, 2013 - All rights reserved - * License: GNU Affero V3 (see LICENSE file) - */ - -#import -#import - -@interface HYBHybridge : NSObject - -/** - * Current Native Hybridge version - */ -extern int const kVersion; - -/** - * String constants referencing defined Hybridge native events - */ -extern NSString * const kHybridgeEventPause; -extern NSString * const kHybridgeEventResume; -extern NSString * const kHybridgeEventMessage; -extern NSString * const kHybridgeEventReady; - -/** - * Defined block to be used as handler of each action. - * - * @param NSURLProtocol* Contains request information - * @param NSString* JSON string sent from the Javascript call - * @param NSHTTPURLResponse* HTTP response - */ -typedef void (^HybridgeHandlerBlock_t)(NSURLProtocol*, NSString*, NSHTTPURLResponse*); - -/** - * Singleton constructor - * - * @return single Hibridge instance - */ -+ (HYBHybridge *)sharedInstance; - -/** - * Returns the actual list of available native actions - * - * @return list of actions - */ -- (NSDictionary *)getActions; - -/** - * Execute Javascript code in WebView - * - * @param js Javastring code String - * @param webview target WebView - * - * @return String returned by Javascript code. - */ -- (NSString *)runJsInWebview:(NSString *)js web:(UIWebView*) webview; - -/** - * Trigger Hybridge event in Webview - * - * @param eventName Event type - * @param jsonString JSON data to attach to the event - * @param webview target WebView - */ -- (void)fireEventInWebView:(NSString *)eventName data:(NSString *)jsonString web:(UIWebView*) webview; - -/** - * Add block handler to current list of supported native actions - * - * @param action action name - * @param handlerBlock handler block - */ -- (void)subscribeAction:(NSString *)action withHandler:(HybridgeHandlerBlock_t)handlerBlock; - -/** - * Initialices Javascript HybridgeGlobal object in WebView - * - * @param webview target WebView - */ -- (void)initJavascript:(UIWebView*) webview; - -@end diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeAppDelegate.h b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeAppDelegate.h deleted file mode 100644 index 06c0765..0000000 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeAppDelegate.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Hybridge - * (c) Telefonica Digital, 2013 - All rights reserved - * License: GNU Affero V3 (see LICENSE file) - */ - -#import -#import "WebViewController.h" - -@interface HybridgeAppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; -@property (strong, nonatomic) WebViewController *viewController; - -@end diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/WebViewController.h b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/WebViewController.h deleted file mode 100644 index a5b9e3a..0000000 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/WebViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Hybridge - * (c) Telefonica Digital, 2013 - All rights reserved - * License: GNU Affero V3 (see LICENSE file) - */ - -#import -#import "HYBHybridge.h" - -@interface WebViewController : UIViewController - -@property (strong) UIWebView *webview; - -- (void) fireJavascriptEvent:(NSString *)eventName data:(NSString *)jsonString; - -@end - diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/WebViewController.m b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/WebViewController.m deleted file mode 100644 index 5503af4..0000000 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/WebViewController.m +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Hybridge - * (c) Telefonica Digital, 2013 - All rights reserved - * License: GNU Affero V3 (see LICENSE file) - */ - -#import "WebViewController.h" -#import "HYBHybridge.h" - -@interface WebViewController () -{ - @private HYBHybridge *_hybridge; -} -@end - -@implementation WebViewController - -NSString *_targetURL = @"http://127.0.0.1/hybridge.html"; - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - - } - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - // Hybridge binding - _hybridge = [HYBHybridge sharedInstance]; - - // Handlers - - // Example handler, just parses data to JSON from ajax header in order to process it - // and writes back JSON in a response header - HybridgeHandlerBlock_t initHandler = ^(NSURLProtocol *url, NSString *data, NSHTTPURLResponse *response) { - - NSData *jsonData = [data dataUsingEncoding:NSUTF8StringEncoding]; - NSError *error = nil; - NSDictionary *params = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error]; - - BOOL hybridgeInitialized = [[params objectForKey:@"initialized"] boolValue]; - if (hybridgeInitialized) { - [self fireJavascriptEvent:kHybridgeEventReady data:(NSString*) @"{}"]; - } - }; - - [_hybridge subscribeAction:@"init" withHandler:initHandler]; - - self.webview = [[UIWebView alloc] initWithFrame:self.view.bounds]; - self.webview.delegate = self; - self.webview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - [self.view addSubview:self.webview]; - - // Load local HTML - //NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"index" ofType:@"html"]; - //NSURL *url = [NSURL fileURLWithPath:filePath]; - - // Load HTTP - NSURL*url = [NSURL URLWithString:_targetURL]; - - [self.webview loadRequest:[NSURLRequest requestWithURL:url]]; -} - -- (void)webViewDidFinishLoad:(UIWebView *)webView -{ - [_hybridge initJavascript:self.webview]; -} - -- (void) fireJavascriptEvent:(NSString *)eventName data:(NSString *)jsonString -{ - [_hybridge fireEventInWebView:eventName data:jsonString web:self.webview]; -} - -@end diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/libHybridge.a b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/libHybridge.a deleted file mode 100644 index b127baa..0000000 Binary files a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/libHybridge.a and /dev/null differ diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/main.m b/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/main.m deleted file mode 100644 index 0062f13..0000000 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/main.m +++ /dev/null @@ -1,18 +0,0 @@ -// -// main.m -// HybridgeBoilerplate -// -// Created by David Garcia on 06/11/13. -// Copyright (c) 2013 tid.es. All rights reserved. -// - -#import - -#import "HybridgeAppDelegate.h" - -int main(int argc, char * argv[]) -{ - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([HybridgeAppDelegate class])); - } -} diff --git a/boilerplate/ios/HybridgeSample/.gitignore b/boilerplate/ios/HybridgeSample/.gitignore new file mode 100644 index 0000000..0e7bb72 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/.gitignore @@ -0,0 +1,22 @@ +# System +.DS_Store +# Subversion +.svn +# Xcode +build/* +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +xcuserdata +profile +*.moved-aside +# AppCode +.idea +#Cocoapods +Pods diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample.xcodeproj/project.pbxproj b/boilerplate/ios/HybridgeSample/HybridgeSample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..59b32af --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample.xcodeproj/project.pbxproj @@ -0,0 +1,504 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 99801D1D18F2910F0027FC7A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99801D1C18F2910F0027FC7A /* Foundation.framework */; }; + 99801D1F18F2910F0027FC7A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99801D1E18F2910F0027FC7A /* CoreGraphics.framework */; }; + 99801D2118F2910F0027FC7A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99801D2018F2910F0027FC7A /* UIKit.framework */; }; + 99801D2718F2910F0027FC7A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 99801D2518F2910F0027FC7A /* InfoPlist.strings */; }; + 99801D2918F2910F0027FC7A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 99801D2818F2910F0027FC7A /* main.m */; }; + 99801D2D18F2910F0027FC7A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 99801D2C18F2910F0027FC7A /* AppDelegate.m */; }; + 99801D3818F291100027FC7A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 99801D3718F291100027FC7A /* Images.xcassets */; }; + 99801D3F18F291100027FC7A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99801D3E18F291100027FC7A /* XCTest.framework */; }; + 99801D4018F291100027FC7A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99801D1C18F2910F0027FC7A /* Foundation.framework */; }; + 99801D4118F291100027FC7A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99801D2018F2910F0027FC7A /* UIKit.framework */; }; + 99801D4918F291100027FC7A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 99801D4718F291100027FC7A /* InfoPlist.strings */; }; + 99801D4B18F291100027FC7A /* HybridgeSampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99801D4A18F291100027FC7A /* HybridgeSampleTests.m */; }; + 99801D5618F295670027FC7A /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 99801D5518F295670027FC7A /* WebViewController.m */; }; + B785C3222F884EA28C6EA1BA /* libPods-HybridgeSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3120090FCC9B40F4BA0C73DE /* libPods-HybridgeSample.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 99801D4218F291100027FC7A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 99801D1118F2910F0027FC7A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 99801D1818F2910F0027FC7A; + remoteInfo = HybridgeSample; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 3120090FCC9B40F4BA0C73DE /* libPods-HybridgeSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HybridgeSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 99801D1918F2910F0027FC7A /* HybridgeSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HybridgeSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 99801D1C18F2910F0027FC7A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 99801D1E18F2910F0027FC7A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 99801D2018F2910F0027FC7A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 99801D2418F2910F0027FC7A /* HybridgeSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HybridgeSample-Info.plist"; sourceTree = ""; }; + 99801D2618F2910F0027FC7A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 99801D2818F2910F0027FC7A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 99801D2A18F2910F0027FC7A /* HybridgeSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HybridgeSample-Prefix.pch"; sourceTree = ""; }; + 99801D2B18F2910F0027FC7A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 99801D2C18F2910F0027FC7A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 99801D3718F291100027FC7A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 99801D3D18F291100027FC7A /* HybridgeSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HybridgeSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 99801D3E18F291100027FC7A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + 99801D4618F291100027FC7A /* HybridgeSampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HybridgeSampleTests-Info.plist"; sourceTree = ""; }; + 99801D4818F291100027FC7A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 99801D4A18F291100027FC7A /* HybridgeSampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HybridgeSampleTests.m; sourceTree = ""; }; + 99801D5418F295670027FC7A /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = ""; }; + 99801D5518F295670027FC7A /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = ""; }; + C434E462390044FABE0DB5F7 /* Pods-HybridgeSample.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HybridgeSample.xcconfig"; path = "Pods/Pods-HybridgeSample.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 99801D1618F2910F0027FC7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 99801D1F18F2910F0027FC7A /* CoreGraphics.framework in Frameworks */, + 99801D2118F2910F0027FC7A /* UIKit.framework in Frameworks */, + 99801D1D18F2910F0027FC7A /* Foundation.framework in Frameworks */, + B785C3222F884EA28C6EA1BA /* libPods-HybridgeSample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 99801D3A18F291100027FC7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 99801D3F18F291100027FC7A /* XCTest.framework in Frameworks */, + 99801D4118F291100027FC7A /* UIKit.framework in Frameworks */, + 99801D4018F291100027FC7A /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 99801D1018F2910F0027FC7A = { + isa = PBXGroup; + children = ( + 99801D2218F2910F0027FC7A /* HybridgeSample */, + 99801D4418F291100027FC7A /* HybridgeSampleTests */, + 99801D1B18F2910F0027FC7A /* Frameworks */, + 99801D1A18F2910F0027FC7A /* Products */, + C434E462390044FABE0DB5F7 /* Pods-HybridgeSample.xcconfig */, + ); + sourceTree = ""; + }; + 99801D1A18F2910F0027FC7A /* Products */ = { + isa = PBXGroup; + children = ( + 99801D1918F2910F0027FC7A /* HybridgeSample.app */, + 99801D3D18F291100027FC7A /* HybridgeSampleTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 99801D1B18F2910F0027FC7A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 99801D1C18F2910F0027FC7A /* Foundation.framework */, + 99801D1E18F2910F0027FC7A /* CoreGraphics.framework */, + 99801D2018F2910F0027FC7A /* UIKit.framework */, + 99801D3E18F291100027FC7A /* XCTest.framework */, + 3120090FCC9B40F4BA0C73DE /* libPods-HybridgeSample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 99801D2218F2910F0027FC7A /* HybridgeSample */ = { + isa = PBXGroup; + children = ( + 99801D2B18F2910F0027FC7A /* AppDelegate.h */, + 99801D2C18F2910F0027FC7A /* AppDelegate.m */, + 99801D5418F295670027FC7A /* WebViewController.h */, + 99801D5518F295670027FC7A /* WebViewController.m */, + 99801D3718F291100027FC7A /* Images.xcassets */, + 99801D2318F2910F0027FC7A /* Supporting Files */, + ); + path = HybridgeSample; + sourceTree = ""; + }; + 99801D2318F2910F0027FC7A /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 99801D2418F2910F0027FC7A /* HybridgeSample-Info.plist */, + 99801D2518F2910F0027FC7A /* InfoPlist.strings */, + 99801D2818F2910F0027FC7A /* main.m */, + 99801D2A18F2910F0027FC7A /* HybridgeSample-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 99801D4418F291100027FC7A /* HybridgeSampleTests */ = { + isa = PBXGroup; + children = ( + 99801D4A18F291100027FC7A /* HybridgeSampleTests.m */, + 99801D4518F291100027FC7A /* Supporting Files */, + ); + path = HybridgeSampleTests; + sourceTree = ""; + }; + 99801D4518F291100027FC7A /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 99801D4618F291100027FC7A /* HybridgeSampleTests-Info.plist */, + 99801D4718F291100027FC7A /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 99801D1818F2910F0027FC7A /* HybridgeSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 99801D4E18F291100027FC7A /* Build configuration list for PBXNativeTarget "HybridgeSample" */; + buildPhases = ( + ECD114C2A7DE442998F017F8 /* Check Pods Manifest.lock */, + 99801D1518F2910F0027FC7A /* Sources */, + 99801D1618F2910F0027FC7A /* Frameworks */, + 99801D1718F2910F0027FC7A /* Resources */, + C49777CD2ED34275891E9FEA /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HybridgeSample; + productName = HybridgeSample; + productReference = 99801D1918F2910F0027FC7A /* HybridgeSample.app */; + productType = "com.apple.product-type.application"; + }; + 99801D3C18F291100027FC7A /* HybridgeSampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 99801D5118F291100027FC7A /* Build configuration list for PBXNativeTarget "HybridgeSampleTests" */; + buildPhases = ( + 99801D3918F291100027FC7A /* Sources */, + 99801D3A18F291100027FC7A /* Frameworks */, + 99801D3B18F291100027FC7A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 99801D4318F291100027FC7A /* PBXTargetDependency */, + ); + name = HybridgeSampleTests; + productName = HybridgeSampleTests; + productReference = 99801D3D18F291100027FC7A /* HybridgeSampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 99801D1118F2910F0027FC7A /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + ORGANIZATIONNAME = "Telefonica I+D"; + TargetAttributes = { + 99801D3C18F291100027FC7A = { + TestTargetID = 99801D1818F2910F0027FC7A; + }; + }; + }; + buildConfigurationList = 99801D1418F2910F0027FC7A /* Build configuration list for PBXProject "HybridgeSample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 99801D1018F2910F0027FC7A; + productRefGroup = 99801D1A18F2910F0027FC7A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 99801D1818F2910F0027FC7A /* HybridgeSample */, + 99801D3C18F291100027FC7A /* HybridgeSampleTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 99801D1718F2910F0027FC7A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 99801D3818F291100027FC7A /* Images.xcassets in Resources */, + 99801D2718F2910F0027FC7A /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 99801D3B18F291100027FC7A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 99801D4918F291100027FC7A /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + C49777CD2ED34275891E9FEA /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Pods-HybridgeSample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + ECD114C2A7DE442998F017F8 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 99801D1518F2910F0027FC7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 99801D2D18F2910F0027FC7A /* AppDelegate.m in Sources */, + 99801D5618F295670027FC7A /* WebViewController.m in Sources */, + 99801D2918F2910F0027FC7A /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 99801D3918F291100027FC7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 99801D4B18F291100027FC7A /* HybridgeSampleTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 99801D4318F291100027FC7A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 99801D1818F2910F0027FC7A /* HybridgeSample */; + targetProxy = 99801D4218F291100027FC7A /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 99801D2518F2910F0027FC7A /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 99801D2618F2910F0027FC7A /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 99801D4718F291100027FC7A /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 99801D4818F291100027FC7A /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 99801D4C18F291100027FC7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 99801D4D18F291100027FC7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 99801D4F18F291100027FC7A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C434E462390044FABE0DB5F7 /* Pods-HybridgeSample.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "HybridgeSample/HybridgeSample-Prefix.pch"; + INFOPLIST_FILE = "HybridgeSample/HybridgeSample-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 99801D5018F291100027FC7A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C434E462390044FABE0DB5F7 /* Pods-HybridgeSample.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "HybridgeSample/HybridgeSample-Prefix.pch"; + INFOPLIST_FILE = "HybridgeSample/HybridgeSample-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 99801D5218F291100027FC7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HybridgeSample.app/HybridgeSample"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "HybridgeSample/HybridgeSample-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "HybridgeSampleTests/HybridgeSampleTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Debug; + }; + 99801D5318F291100027FC7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HybridgeSample.app/HybridgeSample"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "HybridgeSample/HybridgeSample-Prefix.pch"; + INFOPLIST_FILE = "HybridgeSampleTests/HybridgeSampleTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 99801D1418F2910F0027FC7A /* Build configuration list for PBXProject "HybridgeSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 99801D4C18F291100027FC7A /* Debug */, + 99801D4D18F291100027FC7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 99801D4E18F291100027FC7A /* Build configuration list for PBXNativeTarget "HybridgeSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 99801D4F18F291100027FC7A /* Debug */, + 99801D5018F291100027FC7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 99801D5118F291100027FC7A /* Build configuration list for PBXNativeTarget "HybridgeSampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 99801D5218F291100027FC7A /* Debug */, + 99801D5318F291100027FC7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 99801D1118F2910F0027FC7A /* Project object */; +} diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample/AppDelegate.h b/boilerplate/ios/HybridgeSample/HybridgeSample/AppDelegate.h new file mode 100644 index 0000000..7953c35 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// HybridgeSample +// +// Created by guille on 07/04/14. +// Copyright (c) 2014 Telefonica I+D. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeAppDelegate.m b/boilerplate/ios/HybridgeSample/HybridgeSample/AppDelegate.m similarity index 59% rename from boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeAppDelegate.m rename to boilerplate/ios/HybridgeSample/HybridgeSample/AppDelegate.m index 1ce2b38..7f2cb2a 100644 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeAppDelegate.m +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/AppDelegate.m @@ -1,49 +1,57 @@ -/** - * Hybridge - * (c) Telefonica Digital, 2013 - All rights reserved - * License: GNU Affero V3 (see LICENSE file) - */ - -#import "HybridgeAppDelegate.h" +// +// AppDelegate.m +// HybridgeSample +// +// Created by guille on 07/04/14. +// Copyright (c) 2014 Telefonica I+D. All rights reserved. +// + +#import "AppDelegate.h" #import "WebViewController.h" -@implementation HybridgeAppDelegate +@interface AppDelegate () + +@property (strong, nonatomic) UINavigationController *navigationController; + +@end + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + NSURL *url = [NSURL URLWithString:@"http://telefonicaid.github.io/tdigital-hybridge/hybridge.html"]; + WebViewController *webViewController = [[WebViewController alloc] initWithURL:url]; + + self.navigationController = [[UINavigationController alloc] initWithRootViewController:webViewController]; + self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; + self.window.rootViewController = self.navigationController; + + return YES; +} -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - // Override point for customization after application launch. - self.window.backgroundColor = [UIColor whiteColor]; +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self.window makeKeyAndVisible]; - self.viewController = [[WebViewController alloc] init]; - self.window.rootViewController = self.viewController; return YES; } -- (void)applicationWillResignActive:(UIApplication *)application -{ +- (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } -- (void)applicationDidEnterBackground:(UIApplication *)application -{ - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } -- (void)applicationWillEnterForeground:(UIApplication *)application -{ +- (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } -- (void)applicationDidBecomeActive:(UIApplication *)application -{ +- (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } -- (void)applicationWillTerminate:(UIApplication *)application -{ +- (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeBoilerplate-Info.plist b/boilerplate/ios/HybridgeSample/HybridgeSample/HybridgeSample-Info.plist similarity index 75% rename from boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeBoilerplate-Info.plist rename to boilerplate/ios/HybridgeSample/HybridgeSample/HybridgeSample-Info.plist index eb3f0b5..6654099 100644 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeBoilerplate-Info.plist +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/HybridgeSample-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - tid.es.${PRODUCT_NAME:rfc1034identifier} + es.tid.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -28,18 +28,21 @@ armv7 + UIStatusBarTintParameters + + UINavigationBar + + Style + UIBarStyleDefault + Translucent + + + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch b/boilerplate/ios/HybridgeSample/HybridgeSample/HybridgeSample-Prefix.pch similarity index 75% rename from boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch rename to boilerplate/ios/HybridgeSample/HybridgeSample/HybridgeSample-Prefix.pch index 743435c..82a2bb4 100644 --- a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/HybridgeBoilerplate-Prefix.pch +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/HybridgeSample-Prefix.pch @@ -6,8 +6,8 @@ #import -#ifndef __IPHONE_3_0 -#warning "This project uses features only available in iOS SDK 3.0 and later." +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." #endif #ifdef __OBJC__ diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample/Images.xcassets/AppIcon.appiconset/Contents.json b/boilerplate/ios/HybridgeSample/HybridgeSample/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a396706 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample/Images.xcassets/LaunchImage.launchimage/Contents.json b/boilerplate/ios/HybridgeSample/HybridgeSample/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..c79ebd3 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample/WebViewController.h b/boilerplate/ios/HybridgeSample/HybridgeSample/WebViewController.h new file mode 100644 index 0000000..7d8308e --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/WebViewController.h @@ -0,0 +1,13 @@ +// +// WebViewController.h +// HybridgeSample +// +// Created by guille on 07/04/14. +// Copyright (c) 2014 Telefonica I+D. All rights reserved. +// + +#import + +@interface WebViewController : HYBWebViewController + +@end diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample/WebViewController.m b/boilerplate/ios/HybridgeSample/HybridgeSample/WebViewController.m new file mode 100644 index 0000000..fb6fba4 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/WebViewController.m @@ -0,0 +1,64 @@ +// +// WebViewController.m +// HybridgeSample +// +// Created by guille on 07/04/14. +// Copyright (c) 2014 Telefonica I+D. All rights reserved. +// + +#import "WebViewController.h" + +@interface WebViewController () + +@end + +@implementation WebViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.title = @"Hybridge"; + self.bridge.delegate = self; +} + +#pragma mark - HYBBridgeDelegate + +- (NSArray *)bridgeActions:(HYBBridge *)bridge { + return @[@"some_action", @"some_other_action"]; +} + +/* + If you name your actions using snake_case (i.e. 'your_action'), the bridge will look for a + a method with the signature `- (NSDictionary *)handleWithData:(NSDictionary *)data` + to handle that action. + */ + +- (NSDictionary *)handleSomeActionWithData:(NSDictionary *)data { + NSLog(@"%s", __PRETTY_FUNCTION__); + + // Send a message event back to the web view + [self.webView hyb_fireEvent:HYBEventMessage data:@{@"method": NSStringFromSelector(_cmd)}]; + + return @{ + @"foo": @"bar" + }; +} + +- (NSDictionary *)handleSomeOtherActionWithData:(NSDictionary *)data { + NSLog(@"%s", __PRETTY_FUNCTION__); + + // Send a message event back to the web view + [self.webView hyb_fireEvent:HYBEventMessage data:@{@"method": NSStringFromSelector(_cmd)}]; + + return nil; +} + +/* If you wish to handle actions in a more generic way, you can implement: + +- (NSDictionary *)bridgeDidReceiveAction:(NSString *)action data:(NSDictionary *)data { + // Handle actions here + return nil; +} +*/ + +@end diff --git a/boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/en.lproj/InfoPlist.strings b/boilerplate/ios/HybridgeSample/HybridgeSample/en.lproj/InfoPlist.strings similarity index 100% rename from boilerplate/ios/HybridgeBoilerplate/HybridgeBoilerplate/en.lproj/InfoPlist.strings rename to boilerplate/ios/HybridgeSample/HybridgeSample/en.lproj/InfoPlist.strings diff --git a/boilerplate/ios/HybridgeSample/HybridgeSample/main.m b/boilerplate/ios/HybridgeSample/HybridgeSample/main.m new file mode 100644 index 0000000..5c3130f --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSample/main.m @@ -0,0 +1,18 @@ +// +// main.m +// HybridgeSample +// +// Created by guille on 07/04/14. +// Copyright (c) 2014 Telefonica I+D. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/boilerplate/ios/HybridgeSample/HybridgeSampleTests/HybridgeSampleTests-Info.plist b/boilerplate/ios/HybridgeSample/HybridgeSampleTests/HybridgeSampleTests-Info.plist new file mode 100644 index 0000000..715c3df --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSampleTests/HybridgeSampleTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + es.tid.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/boilerplate/ios/HybridgeSample/HybridgeSampleTests/HybridgeSampleTests.m b/boilerplate/ios/HybridgeSample/HybridgeSampleTests/HybridgeSampleTests.m new file mode 100644 index 0000000..5d66ecc --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSampleTests/HybridgeSampleTests.m @@ -0,0 +1,34 @@ +// +// HybridgeSampleTests.m +// HybridgeSampleTests +// +// Created by guille on 07/04/14. +// Copyright (c) 2014 Telefonica I+D. All rights reserved. +// + +#import + +@interface HybridgeSampleTests : XCTestCase + +@end + +@implementation HybridgeSampleTests + +- (void)setUp +{ + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown +{ + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample +{ + XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); +} + +@end diff --git a/boilerplate/ios/HybridgeSample/HybridgeSampleTests/en.lproj/InfoPlist.strings b/boilerplate/ios/HybridgeSample/HybridgeSampleTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/boilerplate/ios/HybridgeSample/HybridgeSampleTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/boilerplate/ios/HybridgeSample/Podfile b/boilerplate/ios/HybridgeSample/Podfile new file mode 100644 index 0000000..54f2127 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/Podfile @@ -0,0 +1,11 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, "6.0" + +target "HybridgeSample" do + pod 'Hybridge', :path => '../../..' +end + +target "HybridgeSampleTests" do + +end + diff --git a/boilerplate/ios/HybridgeSample/Podfile.lock b/boilerplate/ios/HybridgeSample/Podfile.lock new file mode 100644 index 0000000..b7fad22 --- /dev/null +++ b/boilerplate/ios/HybridgeSample/Podfile.lock @@ -0,0 +1,14 @@ +PODS: + - Hybridge (1.2.0) + +DEPENDENCIES: + - Hybridge (from `../../..`) + +EXTERNAL SOURCES: + Hybridge: + :path: ../../.. + +SPEC CHECKSUMS: + Hybridge: 9c0600c2faf4ba43b2c66b9fbbc714ce7cbfdc8d + +COCOAPODS: 0.33.1 diff --git a/boilerplate/www/hybridge.html b/boilerplate/www/hybridge.html index c1ffd0e..bf0102a 100644 --- a/boilerplate/www/hybridge.html +++ b/boilerplate/www/hybridge.html @@ -1,26 +1,116 @@ Hybridge Boilerplate - - + -