You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
start and end are easy, pass back the handle and use it in a stop(handle) function
and one could use parms to pass a JS onData and OnError function to the init()
I just don't see ANY example of CALLING the funtion
in the .m
@objc func initScanning(_ call: CAPluginCall){
const parm1=call.getObject("parm1")?? ''
const parm2=call.getObject("parm2") ?? ''
const OnData_callback=call.getObject("onData") ?? nil
const OnError_callback=call.getObject("onError") ?? nil
//returns object
// need a unique id to use on call
try {
const Handle=rawInit(parm1, parm2)
if(Handle){
call.keepAlive = true
saveCall(ID:????)
Handle.onData = { context in
const lastcall=savedCall(withID: String)
//return a common result with a label for the app
lastcall.resolve({onData:context})
or --- somehow call thru OnData_callback(context))
lastcall.resolve()
}
Handle.onError = { context in
const lastcall=savedCall(withID: String)
//return a common result with a label for the app
lastcall.resolve({onEnter:context})
or --- somehow call thru OnError_callback(context))
lastcall.resolve()
}
call.resolve(Handle) // send back to calling app
} else {
call.reject("init failed")
}
} catch(error){
call.reject(error)
}
}
i've seen some plugins use NotifyListeners, but no mention of how the listeners got created. I don't do 'AddListener' in any of my apps with current (v3?) plugins. I mostly get an observable to get events on. in my case the raw api will cause a stream of events at Handle.onData(...) that I want to pass back to the app.
one other nagging question..
the .m shows the (function_name, plugincalltype)
how does function_name get mapped to the app function name? as the function_name in the .m is not a literal. or is it converted to a literal as part of the CAPLUGIN wrapper work.. but this side effect is not mentioned anywhere that I have seen.
got most o the plugin working, except for this last part of the callbacks/event handler interface
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am making a plugin to use in my app.. the raw api looks like
handle=initScanning(xyz)
handle.onData( data){}
handle.onError(data){}
handle.startScanning()
then events flow thru the two on..... handlers
start and end are easy, pass back the handle and use it in a stop(handle) function
and one could use parms to pass a JS onData and OnError function to the init()
I just don't see ANY example of CALLING the funtion
in the .m
i've seen some plugins use NotifyListeners, but no mention of how the listeners got created. I don't do 'AddListener' in any of my apps with current (v3?) plugins. I mostly get an observable to get events on. in my case the raw api will cause a stream of events at Handle.onData(...) that I want to pass back to the app.
one other nagging question..
the .m shows the (function_name, plugincalltype)
how does function_name get mapped to the app function name? as the function_name in the .m is not a literal. or is it converted to a literal as part of the CAPLUGIN wrapper work.. but this side effect is not mentioned anywhere that I have seen.
got most o the plugin working, except for this last part of the callbacks/event handler interface
Beta Was this translation helpful? Give feedback.
All reactions