cordova-plugin-nativeview icon indicating copy to clipboard operation
cordova-plugin-nativeview copied to clipboard

Pass parameters to IOS or Android View

Open ibrahimawadhamid opened this issue 5 years ago • 8 comments

How can I pass parameters from cordova JS when initializing a view to the device native view ?

ibrahimawadhamid avatar Apr 13 '20 07:04 ibrahimawadhamid

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 avatar Apr 13 '20 12:04 mfdeveloper

@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 ?

ibrahimawadhamid avatar Apr 16 '20 07:04 ibrahimawadhamid

@mfdeveloper I believe that you're not using the passed in params in IOS at all.

ibrahimawadhamid avatar Apr 16 '20 11:04 ibrahimawadhamid

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 avatar Apr 17 '20 14:04 mfdeveloper

@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 :(

ibrahimawadhamid avatar Apr 19 '20 08:04 ibrahimawadhamid

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 avatar Apr 19 '20 18:04 mfdeveloper

@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.

ibrahimawadhamid avatar Apr 19 '20 21:04 ibrahimawadhamid

Ok, don't worry @ibrahimawadhamid !! I will add this feature soon :)

mfdeveloper avatar May 02 '20 18:05 mfdeveloper