<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JIBEBUY Blog &#187; CodeProject</title>
	<atom:link href="http://blog.jibebuy.com/category/codeproject/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jibebuy.com</link>
	<description>Save and share homes from your favorite sites without email</description>
	<lastBuildDate>Thu, 04 Sep 2014 17:10:32 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.2</generator>
	<item>
		<title>Real World with AngularJS and Cordova / PhoneGap</title>
		<link>http://blog.jibebuy.com/2014/08/real-world-with-angularjs-and-cordova-phonegap/</link>
		<comments>http://blog.jibebuy.com/2014/08/real-world-with-angularjs-and-cordova-phonegap/#comments</comments>
		<pubDate>Fri, 15 Aug 2014 18:01:16 +0000</pubDate>
		<dc:creator><![CDATA[pj]]></dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Engineering]]></category>
		<category><![CDATA[AngularJS]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[Cordova]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[TwitterBootstrap]]></category>

		<guid isPermaLink="false">http://blog.jibebuy.com/?p=16</guid>
		<description><![CDATA[The main Jibebuy  web app is a single page web app based on AngularJS.  Inspired by reading The Definitive Guide to Angular on Mobile, I decided to spend 1 day porting Jibebuy to Cordova. After just a few hours, I was able to login to Jibebuy on my Android phone! After a couple of days, I had a...]]></description>
				<content:encoded><![CDATA[<p>The main Jibebuy  web app is a single page web app based on <a style="color: #8b8b8b;" href="https://angularjs.org/">AngularJS</a>.  Inspired by reading <a href="http://www.ng-newsletter.com/posts/angular-on-mobile.html">The Definitive Guide to Angular on Mobile</a>, I decided to spend 1 day porting Jibebuy to Cordova. After just a few hours, I was able to login to Jibebuy on my Android phone! After a couple of days, I had a quirky, but mostly working app that could run on both iOS and Android. After that major success, I spent the next several weeks putting a lot of effort small but not inconsequential details like scrolling, properly sizing elements for different devices and handling orientation changes to make sure we had a great mobile experience. In addition, I discovered some important implementation issues &#8211; read below for details.</p>
<hr />
<h2>Handling Device Ready</h2>
<p><em><strong>Contrary to the instructions given in in both the Cordova documentation AND &#8220;The Definitive Guide to Angular on Mobile&#8221;</strong></em>, here is my hard won advice for properly handling the all important <a href="http://cordova.apache.org/docs/en/2.5.0/cordova_events_events.md.html#deviceready">device ready event</a> and <a href="https://docs.angularjs.org/api/ng/function/angular.bootstrap">initializing AngularJS</a>:</p>
<ul>
<li>Include cordova.js as your LAST script include (not first as instructed elsewhere!)</li>
<li>Handle deviceready just before &lt;/body&gt; as shown below:</li>
</ul>
<pre class="brush: jscript; collapse: false; title: ; wrap-lines: false; notranslate">
    &lt;script&gt;
        function handleDeviceReady() {
            console.log(&quot;handleDeviceReady running...&quot;);

            console.log(&quot;handleDeviceReady configuring StatusBar...&quot;);
            StatusBar.overlaysWebView(false);
            StatusBar.backgroundColorByHexString('#009999');
            StatusBar.show();

            console.log(&quot;handleDeviceReady OAuth.initialize...&quot;);
            OAuth.initialize('BlahBlahBlahBlah');

            console.log(&quot;handleDeviceReady angular.boostrap...&quot;);
            angular.bootstrap(document, ['list']);

            console.log(&quot;handleDeviceReady hiding splashscreen...&quot;);
            navigator.splashscreen.hide();

            console.log(&quot;handleDeviceReady checking network connection...&quot;);
            if (navigator.network.connection.type == Connection.NONE) {
                navigator.notification.alert(&quot;No Internet connection&quot;, function() {}, 'Error Loading');
            }

            console.log(&quot;handleDeviceReady complete.&quot;);
        }

        document.addEventListener('DOMContentLoaded', function() {
            console.log(&quot;Adding deviceready event listener...&quot;);
            document.addEventListener('deviceready', handleDeviceReady, false);

            console.log(&quot;Configuring jquery plugins...&quot;);
            $(document).on('click', 'a[href^=http], a[href^=https]', function(e) {
                e.preventDefault();
                var $this = $(this);
                window.open($this.attr('href'), '_blank', 'location=yes', cordova_login_token);
            });
            $('.navbar .btn-navbar').css('display', 'block');

            $('.read-more').readmore();
            $('abbr.timeago').timeago();
            $(&quot;a[href='#top']&quot;).click(function() {
                $(&quot;html, body&quot;).animate({ scrollTop: 0 }, &quot;slow&quot;);
                return false;
            });
        }, false);
    &lt;/script&gt;
</pre>
<p>Note the following about the above code:</p>
<ul>
<li>No weirdness using promises to postpone initialization of AngularJS &#8211; just call angular.bootstrap in the deviceready handler (which is attached in the DOMContentLoaded handler)!</li>
<li>I&#8217;ve included initialization code for other commonly used components such as jQuery controls and OAuth (more about these below).</li>
<li>I&#8217;m showing you the best way I&#8217;ve found to show and hide the status bar if you want a splash screen</li>
</ul>
<h2>OAuth for Social Logins</h2>
<p>Like a lot of apps, Jibebuy lets you login with Facebook, Twitter, etc.. Supporting OAuth and OAuth2 is straightforward (if tedious) for a web app, but these protocols weren&#8217;t designed for mobile apps. I looked into various social auth plugins for Cordova, but the serious ones required installing native SDKs for every platform (so developers would have to install and maintain Facebook SDK for both iOS and Android, for example), and the ones I looked at didn&#8217;t always support both iOS and Android with the same API. I ended up outsourcing to <a href="https://oauth.io/">OAuth.io</a>. Unfortunately, OAuth.io doesn&#8217;t completely insulate you from the tedious details of configuring app keys, URLs, etc. for every provider, but, at least from your app&#8217;s perspective, there is a single API to deal with.</p>
<h2>Scrolling and other Touch Issues</h2>
<p>Much has already been written about the 300ms click delay and I don&#8217;t have anything truly new to contribute on the subject. My advice is to test whatever solution you choose carefully on all your supported devices and platforms. Fortunately, it is easy to handle touch events in AngularJS or whatever.</p>
<p>I wanted scrolling and toolbars to work a particular way in our main window. This ended up taking a lot of time to get working OK (still not perfect) on both iOS and Android. <em><strong>One important scrolling related tip for AngularJS users</strong></em>: Make sure you avoid AngularJS digests if you are trying to handle rapidly fired events like scrolling! I used simple jQuery to handle scrolling in JavaScript.</p>
<h2>Resize and Orientationchange Events</h2>
<p>On iOS under Cordova, you won&#8217;t get a resize event when the orientation changes, but you do get an orientationchange event. I&#8217;m using <a href="http://getbootstrap.com/2.3.2/">Twitter Bootstrap CSS</a> for responsive layout, but I still have some images that need to be resized when the window size changes. Here is the code I ended up with (don&#8217;t hate!):</p>
<pre class="brush: jscript; collapse: false; title: ; wrap-lines: false; notranslate">
    // The block of code below can be used in any scope to call $apply when the window is resized
    var timeoutPromise = null;
    var window = angular.element($window);
    var windowWidth = 0;
    window.on('resize orientationchange', function(e) {
        // console.log('resize or orientationchange: ' + e.type);
        if (timeoutPromise != null)
            $timeout.cancel(timeoutPromise);
        timeoutPromise = $timeout(function() {
            var newWidth = window.width();
            if (!website.isiOs() &amp;&amp; windowWidth == 0) {
                windowWidth = newWidth;
                return;
            } else if (windowWidth == newWidth) {
                return;
            } else {
                windowWidth = newWidth;
                // console.log('resize or orientationchange: broadcast');
                $rootScope.$broadcast('newWindowWidth', newWidth);
            }
        }, 250);
    });
</pre>
<h2>Twitter Bootstrap / Angular Boostrap Modals</h2>
<p>In addition to Twitter Bootstrap, I also use <a href="http://angular-ui.github.io/bootstrap/">Angular UI Bootstrap</a>. Both of these libraries supply a modal component for creating popups. OK, I know modal dialogs are old fashioned, but I find that sometimes, the old, simple ways still work. The modal component supplied by both libraries doesn&#8217;t work well on mobile &#8211; or should I say doesn&#8217;t work at all. Online via Google, I found a lot of possible workarounds. Some were a couple of lines of CSS and others were a couple hundred lines of JavaScript. Though I spent a lot of time on these various ideas, none of them pleased me. In the end, I hacked up the Angular UI Bootstrap modal dialog code to get what I wanted. Since the result is kind of a mess and may eventually be rendered obsolete (Twitter Bootstrap 3.0 used a similar strategy to mine for modal dialogs on mobile), I&#8217;m not posting any code. But, if you need something like this, let me know and I&#8217;ll be happy to share my hacks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jibebuy.com/2014/08/real-world-with-angularjs-and-cordova-phonegap/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Custom WebView/InAppBrowser for iOS and Android for Cordova / PhoneGap App</title>
		<link>http://blog.jibebuy.com/2014/08/custom-webviewinappbrowser-for-ios-and-android-for-cordova-phonegap-app/</link>
		<comments>http://blog.jibebuy.com/2014/08/custom-webviewinappbrowser-for-ios-and-android-for-cordova-phonegap-app/#comments</comments>
		<pubDate>Fri, 15 Aug 2014 16:36:01 +0000</pubDate>
		<dc:creator><![CDATA[pj]]></dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Engineering]]></category>
		<category><![CDATA[AngularJS]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[Cordova]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[PhoneGap]]></category>

		<guid isPermaLink="false">http://blog.jibebuy.com/?p=9</guid>
		<description><![CDATA[The default Cordova InAppBrowser (WebView in iOS terminology) is pretty ugly (different kinds of ugly on iOS and Android) and, besides, we needed to add a Jibebuy toolbar icon so users can save their favorite houses, cars, etc., in Jibebuy. So I decided to figure out how to customize the Cordova InAppBrowser. This required a significant dive...]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.jibebuy.com/wp-content/uploads/2014/08/AndroidBrowser.png"><img class="alignnone size-medium wp-image-10" src="http://blog.jibebuy.com/wp-content/uploads/2014/08/AndroidBrowser-168x300.png" alt="AndroidBrowser" width="168" height="300" /></a> <a href="http://blog.jibebuy.com/wp-content/uploads/2014/08/AndroidBrowserPopup.png"><img class="alignnone size-medium wp-image-11" src="http://blog.jibebuy.com/wp-content/uploads/2014/08/AndroidBrowserPopup-167x300.png" alt="AndroidBrowserPopup" width="167" height="300" /></a></p>
<p>The default Cordova InAppBrowser (WebView in iOS terminology) is pretty ugly (different kinds of ugly on iOS and Android) and, besides, we needed to add a Jibebuy toolbar icon so users can save their favorite houses, cars, etc., in Jibebuy. So I decided to figure out how to customize the Cordova InAppBrowser. This required a significant dive into Objective C and Java native code.</p>
<hr />
<p>My favorite InAppBrowser is the one included with Twitter. It is small, simple and allows you to change orientation (take that Facebook!). The Cordova InAppBrowser is implemented as a plugin. Like many plugins that offer native functionality to Cordova apps, it has different implementations for various platforms. Not all the platforms are supported, but typically, iOS and Android. The Cordova InAppBrowser plugin supports both. As with other native plugins I&#8217;ve used the customization capabilities are limited and different on different platforms. I decided that the &#8220;quick and dirty&#8221; approach was to copy and modify the plugin source code. Fortunately, I had already setup a system to apply patches to Cordova plugins, so, though changing the code is a hack, at least it is repeatable and easy to use.</p>
<p><a href="http://blog.jibebuy.com/wp-content/uploads/2014/08/iOSBrowser.png"><img class="alignnone size-medium wp-image-12" src="http://blog.jibebuy.com/wp-content/uploads/2014/08/iOSBrowser-169x300.png" alt="iOSBrowser" width="169" height="300" /></a> <a href="http://blog.jibebuy.com/wp-content/uploads/2014/08/iOSBrowserPopup.png"><img class="alignnone size-medium wp-image-13" src="http://blog.jibebuy.com/wp-content/uploads/2014/08/iOSBrowserPopup-169x300.png" alt="iOSBrowserPopup" width="169" height="300" /></a></p>
<p>As you can see in the images above, I was able to add the Jibebuy icon and popup to the browser&#8217;s toolbar. The popup is another WebView that runs the same HTML, CSS and JavaScript as our Chrome Browser Extension!</p>
<p>One quirk about my design is that, because the address bar is editable, Jibebuy allows &#8220;unrestricted web access&#8221;  and is tagged with “You must be at least 17 years old to download this app” on the iOS App Store. Other apps like Facebook and Twitter avoid this designation by only allowing you to open URLs input into other parts of their app &#8211; the URL in their InAppBrowser&#8217;s toolbar is read only. Personally, I think this is a silly distinction, but Apple is the gatekeeper for their walled garden! If we get questions or complaints, I can change the control to be read only (as was the default for the stock Cordova InAppBrowser).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jibebuy.com/2014/08/custom-webviewinappbrowser-for-ios-and-android-for-cordova-phonegap-app/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>iTunes / iOS / Android App Store Approval for Cordova / PhoneGap Apps</title>
		<link>http://blog.jibebuy.com/2014/08/ios-android-app-store-approval-for-cordova-phonegap/</link>
		<comments>http://blog.jibebuy.com/2014/08/ios-android-app-store-approval-for-cordova-phonegap/#comments</comments>
		<pubDate>Thu, 14 Aug 2014 19:22:25 +0000</pubDate>
		<dc:creator><![CDATA[pj]]></dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Engineering]]></category>
		<category><![CDATA[AngularJS]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[Cordova]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[PhoneGap]]></category>

		<guid isPermaLink="false">http://blog.jibebuy.com/?p=1</guid>
		<description><![CDATA[Back in July, we put the finishing touches on our Jibebuy 1.0 mobile apps and submitted them to the Apple and Google app stores for approval. Here are the highlights: The 1.0 version app was &#8220;Waiting for Review&#8221; for about 7 days, then &#8220;In Review&#8221; for about 4 hours. The 1.1 version update was &#8220;Waiting...]]></description>
				<content:encoded><![CDATA[<p>Back in July, we put the finishing touches on our Jibebuy 1.0 mobile apps and submitted them to the Apple and Google app stores for approval. Here are the highlights:</p>
<ul>
<li>The 1.0 version app was &#8220;Waiting for Review&#8221; for about 7 days, then &#8220;In Review&#8221; for about 4 hours.</li>
<li>The 1.1 version update was &#8220;Waiting for Review&#8221; for about 7 days, then &#8220;In Review&#8221; for about 4 minutes.</li>
</ul>
<hr />
<p>The update was approved at 1:16pm today. 5 hours later, I could it on the app store and my phone (it might have been available earlier, but I checked at 6:18pm):</p>
<ul>
<li><a href="https://itunes.apple.com/us/app/jibebuy/id886393887">https://itunes.apple.com/us/app/jibebuy/id886393887</a></li>
</ul>
<p>I didn&#8217;t get any questions or comments from Apple &#8211; just an anonymous email saying the status had changed.</p>
<h2>Cordova/PhoneGap App Background Info</h2>
<p>The main Jibebuy  web app is a single page web app based on <a href="https://angularjs.org/">AngularJS</a>. We were able to quickly turn our web app into mobile apps for iOS and Android with <a href="http://cordova.apache.org/">Apache Cordova</a>. (We also have a 100% native iOS app, but that is another story.) We weren&#8217;t sure if we would get approved with a Cordova based app, but you can see that we did. I studied the <a href="https://developer.apple.com/appstore/resources/approval/guidelines.html">App Store Review Guidelines</a> pretty carefully and I felt like we did a pretty good job hitting all the key points. The Review Guidelines incorporate the <a href="https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/">iOS Human Interface Guidelines</a> by reference. There are a few areas, like putting a logo in the header, where we went against the advice given and a few other areas where I wasn&#8217;t 100% sure but decided to submit and see what happens.</p>
<p>I don&#8217;t want to give anybody the wrong idea &#8211; even though our app is Cordova based and mostly uses the same code as our responsive Angular web app, we didn&#8217;t just wrap up an existing multi-page web site. We put a lot of effort into small but not inconsequential details like scrolling, properly sizing elements for different devices and handling orientation changes to make sure we had a great mobile experience.</p>
<h2>You must be at least 17 years old to download this app</h2>
<p>Also of note &#8211; we are tagged with &#8220;You must be at least 17 years old to download this app&#8221; due to &#8220;Unrestricted Web Access&#8221;. When I filled out the forms on the app store, it was clear to me that this would be the case, but I didn&#8217;t know this was going to happen during development of the app. The reason for this tag is because we incorporate a web browser that lets you type URLs directly into the address bar. In contrast, the app browsers in Facebook, Twitter, etc. do not let you type URLs directly &#8211; you have to type the URL a post or tweet, then click on the link in your post.</p>
<p>If you want to see a Cordova app in action (on iOS or Android), feel free to download Jibebuy and create a list. It is a free service, developed by your fellow NextSpacers. You might even find it useful!</p>
<p>Good luck with your own efforts!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jibebuy.com/2014/08/ios-android-app-store-approval-for-cordova-phonegap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
