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

start using JSON-RPC on iOS #1847

Closed
adbenitez opened this issue Apr 27, 2023 · 5 comments
Closed

start using JSON-RPC on iOS #1847

adbenitez opened this issue Apr 27, 2023 · 5 comments

Comments

@adbenitez
Copy link
Member

Android counterpart: deltachat/deltachat-android#2479

Since Delta Chat Desktop and bots starting using JSON-RPC, we have a divergence in the way our clients use core in the three platforms, so to start mitigating this situation the aim is to start by using JSON-RPC for any new API

Async futures in Swift

https://developer.apple.com/videos/play/wwdc2021/10132 minute 32, async futures

class ViewController: UIViewController {
 private var activeContinuation: CheckedContinuation<[Post], Error>?
 func sharedPostsFromPeer() async throws -> [Post] {
  try await withCheckedThrowingContinuation { continuation in
   self.activeContinuation = continuation
   self.peerManager.syncSharedPosts()
 }
}
extension ViewController: PeerSyncDelegate {
 func peerManager (_ manager: PeerManager, received posts: [Post]) {
  self.activeContinuation?.resume (returning: posts)
  self.activeContinuation = nil // guard against multiple calls to resume
 }
 func peerManager (_ manager: PeerManager, hadError error: Error) {
   self.activeContinuation?.resume(throwing: error)
   self.activeContinuation = nil // guard against multiple calls to resume
 }
}
@Simon-Laux
Copy link
Member

So while I started implementing it I found out that the apis used code example above and "async/await"-syntax in general are only available in iOS 13 or newer. So unless we want to work with callbacks or use third party libraries like https://github.com/vadymmarkov/When, we need to upgrade min iOS version to 13. (which makes sense anyway because then we could use Swift UI which would make iOS dev and maintainance simpler for us - even though I admit that it kinda hurts me that some people on older iOS devices will not be able to use new versions of DC anymore, on that matter it would make sense to look at our install stats: "how many users are actually under iOS 13?")

@r10s
Copy link
Member

r10s commented May 2, 2023

which makes sense anyway because then we could use Swift UI which would make iOS dev and maintainance simpler for us

while SwiftUI will make completely new code easier, after experiences in the past, there is quite few completely new code.

also, SwiftUI seems to come with its own set of drawbacks, esp. some things are available in ios14, ios15 only, so we may get even more conditional code, cmp eg. https://prograils.com/swift-ui-b2b-app-2022 for this and other drawbacks. plus there is a learning curve, ppl will need to know more to get into ios development (uikit will not disappear any time soon, also as it seems there are limits about what you can do with SwiftUI)

so, i would not bet on SwiftUI on making things enormously better nor see SwiftUI pr jsonrpc as a valid reason for raising min. supported version.

at some point, we will just have the option for SwiftUI anyway.

@r10s
Copy link
Member

r10s commented Jun 8, 2023

there is dc_jsonrpc_blocking_call() now, that should do.

however, regarding size hickups on android (EDIT: probably unrelated, but still), there is no need to add jsonrpc "fast" nor there is a need to track that in an issue. once an api that needs jsonroc, it will be added anyways - and we also get a real-life test immediately.

@r10s
Copy link
Member

r10s commented Oct 5, 2023

no need for an explicit issue, we'll use and add dc_jsonrpc_blocking_call() or whatever is needed when it is needed. probably not far aways, when it comes for adding reactions.

cross-linking #1727 and #1728

@r10s r10s closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
@r10s
Copy link
Member

r10s commented Jan 26, 2024

meanwhile, jsonrpc was needed and added by #2039

@r10s r10s closed this as completed Jan 26, 2024
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

No branches or pull requests

3 participants