Saturday, March 08, 2014

Installing Phonegap plugins

Putting this example of installing Phonegap plugins here for myself as reference...

Example using Plugman (for Native workflow; entered from anywhere):
plugman install --platform ios --project ./Phonegap/ios/beepwatch2/platforms/ios --plugin org.apache.cordova.splashscreen

Example using Cordova (for Global workflow; entered from project folder):
cordova plugin add org.apache.cordova.inappbrowser

Saturday, August 24, 2013

Force Phoegap app to maintain focus and not go into background

This one actually took me a second to research and find the answer to. I was putting together a beeping stopwatch app for myself and wanted the app to remain in the foreground but, after about 60 seconds, the app kept going into the background.

Finally, I stumbled on a stackoverflow conversation. Without further ado...

Add the following line to your didFinishLaunchingWithOptions in AppDelegate:
[UIApplication sharedApplication].idleTimerDisabled = YES;


Wednesday, February 06, 2013

Add iAd to PhoneGap Application

This post derives from the SiteKickr Blog post "PhoneGap/Cordova and iAd integration." I got stuck in a couple of spots and decided to attempt to lend a little clarity for anyone else seeking a solution. I've also taken a couple of the comments from that post and integrated here.

1. Click on the "Project Navigator" icon in the left most panel in XCode.



2. Click on the top-most item in your hierarchy. 



3. Click on the Build Phases tab. 



4. Expand "Link Binary with Libraries."



5. Click the + icon to add the iAd.framework to your project.



6. In your App -> Classes folder, open up MainViewController.h, and drop in the following code after any existing #import statements but before @end:

 #import <iAd/iAd.h>
 @interface MainViewController : CDVViewController {  
   ADBannerView *adView;  
 }   



7. Open up MainViewController.m


8. In your viewDidUnload method, which should already exist, add:

 [adView release];   



9. In your webViewDidFinishLoad method, add the following just before: 
"return [super webViewDidFinishLoad:theWebView];"

   adView = [[ADBannerView alloc] initWithFrame:CGRectZero];  
   CGRect adFrame = adView.frame;  
   if([UIApplication sharedApplication].statusBarOrientation  
     == UIInterfaceOrientationPortrait  
     || [UIApplication sharedApplication].statusBarOrientation  
     == UIInterfaceOrientationPortraitUpsideDown) {  
     adView.currentContentSizeIdentifier =  
       ADBannerContentSizeIdentifierPortrait;  
     adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;  
   } else {  
     adView.currentContentSizeIdentifier =  
       ADBannerContentSizeIdentifierLandscape;  
     adFrame.size.width = adView.frame.size.width;  
     adFrame.origin.y = self.view.frame.size.width-adView.frame.size.height;  
   }  
   adView.frame = adFrame;  
   [self.view addSubview:adView];  


10. If you don't already have a willAnimateRotationToInterfaceOrientation method, add it, and drop in the following code:

   BOOL hide = (newInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || newInterfaceOrientation == UIInterfaceOrientationLandscapeRight);  
   [[UIApplication sharedApplication] setStatusBarHidden:hide withAnimation:UIStatusBarAnimationNone];  
   CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];  
   [self.view setFrame:mainFrame];  
   if (newInterfaceOrientation != UIInterfaceOrientationLandscapeLeft && newInterfaceOrientation != UIInterfaceOrientationLandscapeRight) {  
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;  
     [self.view bringSubviewToFront:adView];  
     adView.frame = CGRectMake(0.0, self.view.frame.size.height - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);  
   }  
   else {  
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;  
     [self.view bringSubviewToFront:adView];  
     adView.frame = CGRectMake(0.0, self.view.frame.size.width - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);  
   }  


A couple of points of note regarding ad placement:
- iAd is not like Adwords or Admob. Ad placement is not done in your HTML and does not use your javascript or CSS.

- By default, the ad will be placed on the bottom of your app's UI. To change the position of the ad, you'll need to edit all instances of the value of adFrame.origin.y to equal 0 (adFrame.origin.y=0).

- After you're done and ready to deploy, you'll need to enable iAd in your application through iConnect. Keep in mind you can only do this AFTER you upload your app.

  1. Log in to iTunes Connect
  2. Click on "Manage Your Applications"
  3. Click on the App you want to enable iAd on.
  4. Click on the blue "Set Up iAd Network" button.
  5. Follow the instructions.

That's it! Good luck.

UPDATE 03.06.2013: Check out this great response at StackOverflow regarding not showing the ad placeholder if an ad is not delivered: http://stackoverflow.com/a/14764349/2037540

UPDATE 04.17.2013: Brandon Hawkins has come up with a great solution to deal with the issue of the ad frame setting on top of the webview. Check it out here: http://hawkinbj.wordpress.com/2013/04/16/implement-iad-banner-ads-without-covering-uiwebview-in-phonegap/

Tuesday, November 27, 2012

Installing PIL on a Mac

After much torment, and many failures, PIL is now installed. And, it is embarrassing just how simple it ended up being. I'm leaving this here so when I move to my next dev box, I don't spend three days figuring out again.

At the time of this writing, I was running OSX 10.8.2 but I'm sure this will work on earlier versions and probably subsequent versions for some time.

1. Open Terminal
2. Type: sudo easy_install pip
3. Type: sudo pip install PIL

Thanks to klobucar at StackOverflow for his answer regarding installing PIP.


Saturday, November 03, 2012

Updates Posted to the Classic ASP VBScript OAuth Library

There's been a bit of drama over at the Classic ASP VBScript OAuth board regarding twitter's recent API URL changes.  All is well now as the project has been updated and a new example project zip uploaded.

Essentially, it boils down to some Constant URL changes in one of the files. You can read more about it and download the latest version at the Classic ASP VBScript OAuth site.

Tuesday, April 10, 2012

Delete all pyc files

Scenario: You've just pushed a slew of compiled python files 
Solution:
1. Terminal into your project directory
2. Enter: 'find . -type f -name "*.pyc" -delete;' (without the quotes)
3. Add a .gitignore file to the root of your project with '*.pyc' as its content
4. Re-push the project

Thursday, September 22, 2011

Google App Engine Localhost from Parallels


This post is for developers using a MAC, developing on the Google App Engine platform, attempting to connect to their development environment from Windows on Parallels to test browser compatibility.

NOTE: This post was updated on March 25th, 2013 to accommodate changes made to the GAE Python Development Server.

Again, you are:
1. Developing on a MAC.
2. Atop of Google App Engine
3. Using Parallels for browser testing

Setup:
1. On your MAC, open Google App Engine's Launcher application
2. Double click on the project you're attempting to connect to
3. In the "Extra Flags" field, enter "--address=0.0.0.0" (without the quotes) and hit the "Update" button.
4. Make sure the Windows firewall is OFF in your Parallels Windows instance.

That's it, open a browser in your Parallels Windows instance and hit the local network IP address of your MAC using the port delegation from Google App Engine launcher. For instance, if your MAC's IP address is 192.168.0.2, and your project's Google App Engine port is 8101, the address you put in your Parallels browser may be http://192.168.0.2:8101.

Voila.