如何在对应的Nativescript中集成平台依赖的SDKsOS
How to integrate platform dependent SDKs in Nativescript on the corresponding OS
我想尝试将 Braintree SDK 集成到现有的 NativeScript-Mobile App 中。由于 SDK 仅适用于其原生平台,因此我考虑使用 NS-Marshalling 在相应的 OS.
上执行平台相关的 SDK
因为我很确定它不会那么容易,所以我考虑了两种可能性:
实现依赖于相应语言的模块平台(例如 iOS - Objective-C/Swift),就像在 Braintree 方面提到的那样(https://developers.braintreepayments.com/start/hello-client/ios/v3),并从 NativeScript 中集成它们的平台依赖(我把它想象成一个模块,我说使用这个对象列表,我收到 "payment successful" 或 "payment failed" 响应)。 OS-Dependend 模块将完成剩下的工作(评估、SDK 交互等)。
另一种方法是将每一段代码编组到 JS 模块中并执行依赖于 JS 模块的平台。我缺少的只是集成模块的可能性,因为我不知道我应该如何通过 JavaScript 导入和访问“-Library(我什至认为这是不可能的)。
您如何看待这种方法?是否可以用一种或另一种方式来做?
您可以使用本机库(例如 CocoaPods, dynamic and static libraries for iOS and *.aar and *.jar for Android) in NativeScript and access them through JavaScript/TypeScript. The best approach, in my opinion, would be to create a NativeScript plugin and expose the needed functionality via JavaScript/TypeScript by using data conversion (marshalling for iOS)
(和 here the respective article for Android)
根据 Android 的推荐,您也可以 add dependencies to a library through the gradle file
我想尝试将 Braintree SDK 集成到现有的 NativeScript-Mobile App 中。由于 SDK 仅适用于其原生平台,因此我考虑使用 NS-Marshalling 在相应的 OS.
上执行平台相关的 SDK因为我很确定它不会那么容易,所以我考虑了两种可能性: 实现依赖于相应语言的模块平台(例如 iOS - Objective-C/Swift),就像在 Braintree 方面提到的那样(https://developers.braintreepayments.com/start/hello-client/ios/v3),并从 NativeScript 中集成它们的平台依赖(我把它想象成一个模块,我说使用这个对象列表,我收到 "payment successful" 或 "payment failed" 响应)。 OS-Dependend 模块将完成剩下的工作(评估、SDK 交互等)。
另一种方法是将每一段代码编组到 JS 模块中并执行依赖于 JS 模块的平台。我缺少的只是集成模块的可能性,因为我不知道我应该如何通过 JavaScript 导入和访问“-Library(我什至认为这是不可能的)。
您如何看待这种方法?是否可以用一种或另一种方式来做?
您可以使用本机库(例如 CocoaPods, dynamic and static libraries for iOS and *.aar and *.jar for Android) in NativeScript and access them through JavaScript/TypeScript. The best approach, in my opinion, would be to create a NativeScript plugin and expose the needed functionality via JavaScript/TypeScript by using data conversion (marshalling for iOS) (和 here the respective article for Android)
根据 Android 的推荐,您也可以 add dependencies to a library through the gradle file