Pass parameters to IOS or Android View
How can I pass parameters from cordova JS when initializing a view to the device native view ?
Hello @ibrahimawadhamid
You can pass params property to the show() method, like this:
cordova.plugins.NativeView.show({
// Others properties documented in README
...
params: {
"toNative": "a custom value",
"aBooleanValue": true
"aIntValue": 2
}
});
By now, you can pass only basic js types, like: String, Boolean and Integer
I will update the README.md with this information in future :)
@mfdeveloper sorry to bother, I'm a new in all of this, but how can you access the passed parameters in IOS or Android. Can you provide an example please ?
@mfdeveloper I believe that you're not using the passed in params in IOS at all.
Yeah @ibrahimawadhamid, you are completly right! I saw the code, and the params property passed from js, is catched just in Android implementation by now. I don't remember exatly why, but I think that need some extra steps to do a json convertion in IOS implementation with Objective-C, and when I've using this plugin, the project that I was working, don't need params in IOS
Is not complicated to do this, but I can't alloc time now to implementations in this repo, because I'm busy with others projects 😢
Can you implement this and send a pull request?
@mfdeveloper I have zero experience with iOS development. I come from a web development background, so this is all new to me. There's not much I can do in here :(
I understand you completly @ibrahimawadhamid. So, I will try to do this in the next weekend.
But, how can will you get the parameters in IOS, if you don't know nothing about Swift/Objective-C? Someone else will do that for you?
Remember: This plugin is to open a NATIVE screen (ViewController on IOS and Activity on Android).
@mfdeveloper , I'm currently working with a colleague of mine on a project where we'll use your plugin on both Android and iOS, we haven't had a problem on Android, unfortunately on iOS it didn't go through since the code is incomplete and we don't have much knowledge with iOS. I'm trying to figure things out, but the progress is terribly slow.
Ok, don't worry @ibrahimawadhamid !! I will add this feature soon :)