Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support retrieval of NSNumber values from CAPPluginCall options #4303

Closed
wants to merge 1 commit into from

Conversation

lincolnthree
Copy link

There is no current shortcut to retrieve NSNumber values from CAPPluginCall options (only NSString and BOOL are currently supported).

This PR adds the missing convenience method which is required for retrieving numeric and numeric enum values passed through native plugins via the IOS capacitor bridge.

@lincolnthree
Copy link
Author

Forgive me if this PR does not conform to process. It was submitted via Github UI. Happy to update but I am not an iOS developer so this is about as good as it gets from me so far. Happy to learn :)

@ikeith
Copy link
Contributor

ikeith commented Mar 9, 2021

Thank you for the PR!

This PR highlighted the fact that these accessors on CAPPlugin had been overlooked so we appreciate you bringing that to our attention. They are deprecated going forward and this will be reflected in the next release. Our preferred pattern is to have the accessors on CAPPluginCall instead. That is a simpler and more ergonomic API than these methods where you have to pass the call as an argument since the call is the object that actually holds the data.

If you are using Swift, the accessors can be found here.

If you are using Obj-C, the accessors can be found here. These now contain the getNumber method you need. (these do require an extra import statement since the methods are not exposed by default to avoid conflicts with the Swift implementations)

So instead of:
[self getNumber:call field:@"foo" defaultValue:@1];
you would use:
[call getNumber:@"foo" defaultValue:@1];

@lincolnthree
Copy link
Author

Thanks, @ikeith - Sounds good. We will update :) Keep up the good work! Love the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants