Not working in IOS 6 #4

Closed
damrbaby opened this Issue Sep 15, 2012 · 16 comments

Comments

Projects
None yet
10 participants

I am getting the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UAAppDelegateSurrogate application:supportedInterfaceOrientationsForWindow:]: unrecognized selector sent to instance 0x8d26840'

I am using Cordova 2.1 (not yet released). The UA plugin was working perfectly on Cordova 2.1 prior to upgrading xcode to 4.5. If I comment out UAAppDelegateSurrogate.m and PushNotificationPlugin.m (effectively disabling Urban Airship) my app runs fine in IOS 6, so the issue is definitely originating in the UA code somewhere.

I figured out that the issue is because for some reason UAAppDelegateSurrogate.m is not sending the method supportedInterfaceOrientationsForWindow to AppDelegate.m. This occurs on Xcode 4.5 (ios 6 sdk) with Cordova 2.1.

A workaround is to copy the method from AppDelegate.m to the bottom of UAAppDelgateSurrogate.m, before @end:

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{    
    // IPhone doesn't support upside down by default, while the IPad does.  Override to allow all orientations always, and let the root view controller decide whats allowed (the supported orientations mask gets intersected).
    NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);
    return supportedInterfaceOrientations;
}

Ultimately I think it's the respondsToSelector method that is responsible for the error, but I'm not sure.

Thanks for the workaround. Hopefully, the plugin will be updated with a fix soon.

jvence commented Oct 2, 2012

Thanks. Works now. Definitely a bug

when can the fix be ready ?

I am surprised we haven't heard anything from Urban Airship, given that their much anticipated out-of-the box PhoneGap integration that is only 2 months old is currently broken. It looks like they are aware of this issue (see this pull request), but it would be nice to at least hear from them and if they have a timeframe for a release that will fix this bug.

So please, Urban Airship, let us know if you are working to fix this!

Strange that this has not been repaired as a pull request is outstanding.

In the meantime, I have also had to patch the handleOpenURL: delegate call to forward the method to the app delegate:

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  return [defaultAppDelegate application:application supportedInterfaceOrientationsForWindow:window];
}

- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url
{
  return [defaultAppDelegate application:application handleOpenURL:url];
}

FWIW, The pull request offers a more general purpose solution.

It looks like this repository hasn't been touched since it was created 3 months ago. It would be really nice if there were at least some kind of comment on the part of Urban Airship clarifying whether they continue planning to support this plugin.

Contributor

mhooge commented Nov 14, 2012

We updated the master branch with a solution.

Note that according to UA support team, this plugin only supports up to PhoneGap 2.2 I found this out after ages of tampering and getting no-where on version 2.5

Contributor

jtowle commented Apr 10, 2013

Check out the LIB-591 branch (https://github.com/urbanairship/phonegap-ua-push/tree/LIB-591) - it contains our work-in-progress mods to support the just-released 2.6.

Thanks for the quick response jtowle :) So please tell me that it will work up to 2.6 i.e. will it work with 2.5?

Contributor

jtowle commented Apr 10, 2013

The only plugin-related changes between 2.5 and 2.6 were related to removing deprecated functionality, so the code in that branch should work for 2.5. We're still in the dev/qa process, though we expect to push something to master within the next week or so.

fermion commented Jun 19, 2013

I'm currently seeing this using PhoneGap 2.8 and UA 1.4.0. Haven't yet tried the fix above and @jtowle's link above (to LIB-591) is dead. Any updates from UA here?

Contributor

jtowle commented Jun 19, 2013

@fermion, The fix for the original issue has already been merged in, so chances are there is a different root cause here. I'm going to close this issue for clarity, but would you mind posting some more details (logs, os version, etc) in a new issue so we can track it there?

Thanks.

jtowle closed this Jun 19, 2013

fermion commented Jun 19, 2013

@jtowle sure thing! I'm not an iOS dev (shocking, right?) by nature, I'll double check and make sure that it's nothing on my end that's causing this. Will file an issue tonight if I can't figure it out.

fermion commented Jun 20, 2013

@jtowle never mind me and my PEBKAC issues. I'll just be over here writing some bugs, causing some crashes that sound vaguely similar to this one. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment