• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

UIApplication Delegate

Engaged ,
Jan 12, 2012 Jan 12, 2012

Copy link to clipboard

Copied

Hi,

I'm trying to figure out how to correctly use the delegate class on an iOS application using a Native Extension.

We've got it figured out and working, but we have a few bugs and I'm not sure if we're going about it the wrong way.

Our basic procedure is to create and set the delegate in the ContextInitializer function like this:

g_delegate = [[PushNotificationsAppDelegate alloc] init];

[[UIApplication sharedApplication] setDelegate:g_delegate];

However this causes a few problems:

If we load the extension at app startup (say in the actionscript main class constructor) the application crashes with an error:

[XXXXDelegate _stageLoaded]: unrecognized selector sent to instance)

If we delay the extension load, it initialises and works as expected, however any subsequent calls to FRE functions fail eg:

FREDispatchStatusEventAsync(g_ctx, (uint8_t*)[@"test" UTF8String], (uint8_t*)[@"test" UTF8String]);

will cause the application to crash with error:

[XXXXDelegate notifyASyncMessages]: unrecognized selector sent to instance

Anyone have any ideas?

Is there some default Delegate class implementation that the extension uses that I'm destroying?

Any help will be greatly appreciated!

Cheers

air native extensions // https://airnativeextensions.com
TOPICS
Development

Views

2.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 16, 2012 Jan 16, 2012

Copy link to clipboard

Copied

Hi mic.archbold, any luck with your issue? actually I am also having same crash and log shows the same "[XXXXDelegate notifyASyncMessages]: unrecognized selector sent to instance" as output. if you have found the issue, then please share, truely appriciate...

Best Wishes,

Sanniv.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 17, 2012 Jan 17, 2012

Copy link to clipboard

Copied

Hi mic.archbold,

just to update on the issue, I was able to rectify this crash issue by overriding those 2 methods in the delegate class although both are empty implementation. It didn't impact on the app though and didn't crash also...

Hope it helps...

Best Wishes,

Sanniv.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2012 Jan 18, 2012

Copy link to clipboard

Copied

Thanks for the help, I'm still working through it but I think the solution lies in runtime injection of methods.

The method you've suggested does get around some of the crashes but it breaks the link between flash and the objc layer, as you're basically destroying the original application delegate.

I'll post something when I've worked through it all.

Cheers

air native extensions // https://airnativeextensions.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 15, 2015 Dec 15, 2015

Copy link to clipboard

Copied

Just for people still finding this topic, the solution is to do some objc method swizzling for adding core AppDelegate method.

See this example form Freshplanet ANE.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 16, 2015 Dec 16, 2015

Copy link to clipboard

Copied

Also when using swizzling you should be aware that ANE's attempting to use the same delegate methods will potentially interfere when using the swizzling method. Generally only the last ANE to perform the swizzle will be the one called as the application delegate.

air native extensions // https://airnativeextensions.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2015 Dec 17, 2015

Copy link to clipboard

Copied

Oh gosh! I wasn't aware of that. I suppose there isn't any way to manage it, unless making only one big ANE per project... ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 17, 2015 Dec 17, 2015

Copy link to clipboard

Copied

LATEST

Yeah it's a common problem with people using multiple ANE's. Of course there are ways around it. We use a Core ANE in the distriqt collection to handle any application delegate level functionality and pass information to other ANE's using a different method.

air native extensions // https://airnativeextensions.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines