Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

iOS and Android native modules have different method signatures #25

Closed
TimoGlastra opened this issue Nov 11, 2020 · 5 comments
Closed

Comments

@TimoGlastra
Copy link
Contributor

See the code samples below. for example proverCreateCredentialReq for iOS and Android sides expect different order of parameters. I guess because they match the native indy library for iOS/Android.

However I think we should abstract that away on the native side and make the call from the JS side the same for both.

public void proverCreateCredentialReq(int walletHandle, String proverDid, String credentialOfferJson, String credentialDefJson, String masterSecretId, Promise promise) {

@objc func proverCreateCredentialReq(_ credOfferJSON: String, credentialDefJSON: String, proverDID: String, masterSecretID: String, walletHandle: NSNumber,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {

@TimoGlastra
Copy link
Contributor Author

@jakubkoci have you by any chance changed your mind about this? :)

I think it would be easier to maintain if we don't include the if / else statements on the JS side and instead handle it on the native side.

To me that is in line with how React Native modules work. You implement the same API in both iOS and Android and expose that to JS so you don't have to worry about it.

Just wanted to bring it up one more time before closing this issue. Otherwise I'll close it and rest my case forever :)

@jakubkoci
Copy link
Contributor

You're right that we could get rid of if statements and that's generally is a good thing :)

Maybe the main reason I feel it's easier for me to do it in that way was that I needed to investigate signatures and data types conversions in Obj-C and Swift. But now when we have that knowledge.

I would keep the if statements when a method is not implemented for a particular platform. Sounds good?

@JamesKEbert
Copy link
Contributor

Just to add my 2 cents--I agree that removing if statements at the JS level seems like a positive thing. But definitely if statements for platform-specific methods that have not been implemented.

@icc-romeu
Copy link
Contributor

For non-implemented methods, I think it would be better to create a placeHolder method on the native side with a "NOT IMPLEMENTED" warning log or even throw an exception. I think the developer must be warned that that method is not implemented and might make the code fail.

But up to you, I don't have an strong opinion.

@jakubkoci
Copy link
Contributor

jakubkoci commented Jul 19, 2021

I'm closing the issue here because this repository is being archived. Issues will be managed in the new repository indy-sdk-react-native. The discussion can continue in hyperledger/indy-sdk-react-native#5

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

No branches or pull requests

4 participants