Showing posts with label phonegap. Show all posts
Showing posts with label phonegap. Show all posts

Saturday, January 5, 2013

Phonegap In App Billing plugin for Android - v2 API

Yesterday I got motivated to make my first PhoneGap contribution.  I planned to add some calls to a couple of API functions that weren't implemented in the plugin.  I don't know Java, but I hoped that I could just copy some parts that were making other API calls and just make the changes for the calls that I needed.

As I started looking at the Java code in the plugin, I noticed that there was basically just one API call being made with a different command message being sent as a parameter.  That wasn't what I was expecting to see.  So I started looking back at the Android API documentation and found that the calls being used in the plugin were from the version 2 (v2) API.  The v3 API is the latest, but just came out in last month or so.  But its quite a bit different.  So essentially the plugin would need a major upgrade to support the v2 API.  Not knowing Java, that seemed to be too much for me, so I had to give up on helping with the plugin :-(

And MonsterCache will just have to get by with the v2 API features for now.  The two v3 features I was trying to implement were:

  • Getting the list of available products and prices from the store.  I can store those myself, but getting them from the Play store may send you a converted currency in other countries, I'm not sure.
  • Consuming items.  In v3 all items in the store are "Managed", meaning Google keeps track of whether a user has bought them so that they don't have to be bought again.  But if your item should able to be bought again -- like in-game currency -- then you have to "consume" the item so that the user can buy it again.  In v2 though, they have "Unmanaged" items, and you can still make those in the Play store, so v2 still works
So once I coded for v2, it looks like Android In App Purchasing is working.  I'll have to have my test user (my wife) run a test tomorrow to be sure.  Google doesn't let you buy your own product.

I also got a JQuery popup dialog working today.  That was very good because I have lots of basic ugly alert() boxes that I could replace now with something that would look better.

Tomorrow I'm going to take a shot at the iOS In App Billing plugin.

Saturday, December 22, 2012

In-App Billing setback

Just when I thought we were so close... in signing up for Apple Developer and Google Developer accounts, I found that both have restrictions that you must use their markets for purchasing any digital goods in the application.  I failed to anticipate that restriction :-(   My in-app purchasing is not done with their markets.  Actually, it isn't even in-app purchasing technically, because I link out to our web site to do a purchase.  That's also against the terms of both companies.

So.... I need to implement in-app billing for both Apple and Android.  Luckily, very recently an in-app billing Phonegap Plugin was made for just that purpose!  Plugins are separate per OS, so that meant I also needed to split the market page into a version for each OS.  I tried the Android one first, and it worked!  You just use Google's test product IDs, and they come back with fake success messages.  So cool to see the Google Play market open for the first time.

But then.... I discovered that the Plugin seems to be missing a few key features I needed, like the purchaseToken and the API call to consume an in-app purchase.  It looks like I may need to do those parts of the plugin myself.  If I succeed in improving the plugin, of course I would want to share those changes with other PhoneGap users.  That means that I've finally made my way to the GitHub community.  I feel like I'm just barely understanding everything I'm doing, so hopefully I don't make a fool of myself there.  It may be too late as I've already tried to message someone and hopefully didn't send the message to a bunch of people :-/

So much to learn!

Sunday, December 16, 2012

iOS progress

Let's start with the good news.  Last week I built the MonsterCache app on the Mac with PhoneGap and it went quite well!  The only thing that didn't go smoothly was installing the Google Analytics plugin for iOS.  Eventually I remembered that I'd already downloaded it in a .zip file with plugins for different phone OS's.  And eventually, I found the instructions for installing the iOS version of the Analytics plugin.  It was exciting to see the first page in the simulator:


This weekend was the first test to load it on someone's actual iPhone.  That didn't go well.  

The first problem was my Apple Developer account.  I thought that I could load the app onto a phone connected to my computer without doing anything with the Developer account. For that reason, I hadn't even signed up for the Developer account yet.  Once I found out we needed to, I went to sign up and found that the approval process can take 24 hours.  So that killed our hopes for trying it that day.  Incidentally, I signed up yesterday afternoon, a Saturday, and haven't heard anything back as of Sunday night.  So I guess maybe they mean 1 business day for approval???

The second problem was that my friend's iPhone was an older one, a 3GS.  That would have been fine if the OS had been kept up to date, but it was still on 4.0.x.  Turns out the version of the iOS SDK that I'm building with in XCode only supports 4.3 or higher.  We hoped we could upgrade, but its not easy to upgrade to any iOS version that isn't the latest.  The latest is 6.0.x and apparently 3GS iPhone's don't run that very well.  So besides the Developer account issue, the particular phone we had wouldn't have worked anyway.

My parents are coming in to town for Christmas and they have iPhones, so looks like they will be my first iOS beta testers.  In the meantime, I changed the "Forgot Password?" handler to send a password reset link instead of the password itself in clear text. I've been needing to do that for a while, so glad to have that off the list!

Wednesday, November 21, 2012

Back button override fixed in Android PhoneGap!

As a long shot, I updated Cordova/PhoneGap from Cordova 2.0 to Cordova 2.2 to see if it would fix my maps issue. It didn't, as I expected.  But it totally fixed another problem that I'd spent a few hours on! LOL

I've always had trouble with the back button closing the Android app.  You'd think it would just go back to the last HTML page you were on, but that (almost) never happens.  Once every 50 times or so that I hit the back button it goes back a page, and I have no idea why.  Usually it closes the app.  So as a workaround, I wanted to override the back button to give the user a confirm message about closing the app.  The examples posted for how to override back button were pretty simple so I could never understand why it didn't work for me.  I always hoped it would magically start working with a Cordova upgrade, and it has!

Now just have to figure out this dang map issue in order for Beta to be ready....