How to set delegate in PluginLibrary so that Controller has it?

I’m trying to implement MFMessageComposeViewController in an enterprise plugin.

So, I have

@interface AppCoronaDelegate:NSObject \<CoronaDelegate, MFMessageComposeViewControllerDelegate\>

When I create the MFMessageComposeViewController in my PluginLibrary::send(), one of the values I have to set in the created controller is

controller.messageComposeDelegate = ???;

So, how do I provide my AppCoronaDelegate in place of ???, so that when the user sends/cancels the SMS view, MFMessageComposeViewControllerDelegate didFinishWithResult will get called so that I can dismiss the SMS view?

None of the tutorials seem to cover the need to provide the delegate. In a pure Obj-C app,

controller.messageComposeDelegate = self;

is what’s done, but you can’t do that when self is a PluginLibrary, as is the case in a plugin.

Do I somehow get the delegate out of the runtime object?

Am I missing something? Thanks for any help!

I just noticed, in http://forums.coronalabs.com/topic/47127-accessing-variablefunction-defined-in-appcoronadelegate/, walter’s comment:

“You’ll also need a way to access the instance of the delegate itself from your plugin.”

That’s exactly what I need to do. Hasn’t anyone actually figured that out? What exactly is the instance of the delegate that can be made available in the plugin and passed to Obj-C? The referenced post’s OP said the AirPrint tutorial helped with other problems, but that tutorial doesn’t address getting an instance of the delegate.

Same problem here RealHandy  :frowning:

I don’t know how to set a delegate in PluginLibrary.

Any help would be great!!!

Olivier

My solution, since I never heard a peep on this one, was to crib from the ad-related plugin examples on github and use a separate delegate, and not try to use CoronaAppDelegate. There has been no word on how to use CoronaAppDelegate in this way, and though not elegant, using a separate does work. Check those enterprise plugin ad examples for how to have a passable-to-objC delegate.

Thanks a lot !

I’m gonna try now :slight_smile:

I found these ad-related plugin examples on github

  • plugins-sample-ads-iAds
  • plugins-sample-ads-InMobi
  • plugins-sample-ads-inneractive
  • plugins-sample-ads-admob

but they are all in Lua.

Did I miss something?

Thanks again

Olivier

Those are the ones. But the plugins on GitHub do contain code that is not in Lua – check the iOS or other folders in the project (I’m writing this from memory on my phone). They have objC code in them that includes creation of a delegate. I feel like inneractive or inmobi were the ones I referenced.

ok thanks again!  :unsure:

I’ve downloaded all the “ad” plugins… I didn’t find any code in objC or ios folders…

Any idea?

Thanks

O.

Okay, back at computer. My mistake – those ad projects are about how to USE a corona plugin. Here’s one of the ones I looked at, which is the code to CREATE a corona ad plugin for Vungle.

https://github.com/Vungle/coronaplugin

Thank you for your help RealHandy  :slight_smile:

Best,

Olivier

It works!  B)

Thank you very much RealHandy!

You’re the boss  :wink:

Best

Olivier

Great! Glad I could help.

I just noticed, in http://forums.coronalabs.com/topic/47127-accessing-variablefunction-defined-in-appcoronadelegate/, walter’s comment:

“You’ll also need a way to access the instance of the delegate itself from your plugin.”

That’s exactly what I need to do. Hasn’t anyone actually figured that out? What exactly is the instance of the delegate that can be made available in the plugin and passed to Obj-C? The referenced post’s OP said the AirPrint tutorial helped with other problems, but that tutorial doesn’t address getting an instance of the delegate.

Still trying to achieve a very similar thing here: https://forums.coronalabs.com/topic/58195-uiimagewritetosavedphotosalbum-unable-to-callback-to-lua/

RealHandy and oromanetti would you be able to offer any advice?

Hi mpayne,

I’m not at my office actually,

I could maybe help you at my return at the end of August…

Sorry 

Best

Olivier

And I only do Corona at home, so I don’t have access now. Can take a look on Saturday, though.

Thanks for getting back to me!

Not to worry oromanetti :slight_smile: hopefully it’ll be solved by then :wink:

If you could RealHandy that would be great!

Many thanks

Same problem here RealHandy  :frowning:

I don’t know how to set a delegate in PluginLibrary.

Any help would be great!!!

Olivier

My solution, since I never heard a peep on this one, was to crib from the ad-related plugin examples on github and use a separate delegate, and not try to use CoronaAppDelegate. There has been no word on how to use CoronaAppDelegate in this way, and though not elegant, using a separate does work. Check those enterprise plugin ad examples for how to have a passable-to-objC delegate.