Understanding basic iOS Plugin

Hello,

I am trying to understand how to build an iOS Plugin for Corona. I did so with Android but cannot understand a basic issue I am having.

With Android, I am able to call a plugin AND have it run with Corona in the background. So, I am able to “listen” to events in the background and push more events as it ran.

With iOS, although I just started and trying to figure it out, it seems like it’s not the case. I simply run the example App with xCode and added 4 lines of code to constantly print “Corona is Running” every half a second, and changed the delay of plugin “show” to 5 seconds.

So, once the “show” is called the Corona engine stops printing, and only continues when I dismiss the native element.

  1. Is this normal?

  2. Is there a way to run them parallelly?

Thank you,

Mars Team

Code:

local library = require "plugin.library" -- This event is dispatched to the global Runtime object -- by `didLoadMain:` in MyCoronaDelegate.mm local function delegateListener( event ) native.showAlert( "Event dispatched from `didLoadMain:`", "of type: " .. tostring( event.name ), { "OK" } ) end Runtime:addEventListener( "delegate", delegateListener ) -- This event is dispatched to the following Lua function -- by PluginLibrary::show() in PluginLibrary.mm local function listener( event ) print( "Received event from Library plugin (" .. event.name .. "): ", event.message ) end library.init( listener ) -- ADDED THIS BLOCK --------------- local function newListener() print("Corona is Running") end timer.performWithDelay( 500, newListener,0 ) ------------------------------------- -- Changed to 5000 from 500 timer.performWithDelay( 5000, function() library.show( "corona" ) end )

Backgrounding with Corona is something you may or may not get to work for you.

First, and foremost, the Corona side has never been “background” tested. There is an assumption that the OpenGL User Interface to process Corona API calls present. While background, this creates an unknown state.

Secondly, on iOS, you have to specify specific background modes in your info.plist. If you don’t Apple won’t give you background access.  

We do not officially support backgrounded Corona apps. If it works, great. But changes in the future may break that functionality.

Rob

Backgrounding with Corona is something you may or may not get to work for you.

First, and foremost, the Corona side has never been “background” tested. There is an assumption that the OpenGL User Interface to process Corona API calls present. While background, this creates an unknown state.

Secondly, on iOS, you have to specify specific background modes in your info.plist. If you don’t Apple won’t give you background access.  

We do not officially support backgrounded Corona apps. If it works, great. But changes in the future may break that functionality.

Rob