cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Propagate OS events to plugins
Date Sun, 17 Nov 2013 16:20:16 GMT
Yep, definitely sounds the same issue I was experiencing.

Although I am not sure whether to put onload=true in plugin.xml really is the right solution
in general.
If you want your app to be started on the first tap it is the only solution.
If you open your app then you can call some method of phonegap-nfc and the plugin is initialized
and you do not have this problem.
A plugin that needs to react to intent filters on Android needs onload=true.
A plugin that needs to react to e.g. a file being opened on IOS needs onload=true because
the plugin needs to register itself for this event.

This not related to phonegap-nfc only. All plugins that need OS-Events currently need onload=true.

But what Cordova is missing is a way for a plugin to express this: I want to get OS-Events
(like onNewIntent on Android) but I do not need to be loaded on startup.

Each line in like this “if (entry.plugin != null) {”
currently prevents an OS-Event to be propagated to a plugin.
The only way to get the event is to set “onload=true” or use a plugin method (thus creating
a plugin instance).

But if the plugin only needs to get events after the app is started (like e.g. reading an
NFC tag through the app) then creating the plugin instance is wasting startup time and memory

I suggest to have
   <param name=”osevents” value=”true” />

and change all the line in PluginManager from

                    “if (entry.plugin != null) {”


                    “if (entry.plugin != null || (entry.osevent==true && entry.createPlugin(,
this.ctx)!=null)) {”

and the parser in PluginManager is simple…

Although this new osevent param would need support in all platforms and docs and tests. Not
a half-hour project…

Have fun

From: Don Coleman []
Sent: Saturday, November 16, 2013 5:37 PM
To: chariotsolutions/phonegap-nfc
Cc: AxelNennker
Subject: [phonegap-nfc] Add onload for android (#105)

See @AxelNennker<> doc updates

Might fix #99<>?

Reply to this email directly or view it on GitHub<>.
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message