Post

Replies

Boosts

Views

Activity

ApplicationWillTerminate - how do i run JS callback?
Hi everyone! Ladies and gents, I am struggling with the issue for 2+ weeks in a raw, still stuck and I appreciate any help / advices / suggestions! What I am dealing with: web page + backend (php), swift app (wkwebview + some native components). What I am trying to achieve: I need to let the web page know my app is changing it's state, by executing some java scripts (one script for "enter background mode", another one for "enter foreground", and so on). What is my issue: I can't handle the case of app termination. Whenever the user is killing the app by home-double-click/swipe up, ApplicationWillTerminate method from AppDelegate is being called, but it fails to execute webView.evaluateJavaScript from here, as far as I was able to understand - due to the closure / completion handler is has, for it is async by design. All other cases are covered, works fine, and with the last one for termination I am desperately stuck. I am playing around with the following code: func applicationWillTerminate(_ application: UIApplication) {         if let callback = unloadListenerCallback {             if callback == "" {                 debugPrint("got null callback - stop listening")                 unloadListenerCallback = nil             }             else {                 jsCallbackInjection(s: callback) //executing JS callback injection into WebView             }         }     } unloadListenerCallback is the string? variable, works as a charm in other cases (just to mention it for clarity). jsCallbackInjection is the function, also works perfectly elsewhere: func jsCallbackInjection(s: String) {         let jscallbackname = s         HomeController.instance.webView?.evaluateJavaScript(jscallbackname) { (result, error) in              if error == nil {                  print(result as Any)                  print("Executed js callback: \(jscallbackname)")              } else {                  print("Error is \(String(describing: error)), js callback is: \(jscallbackname)")              }          }     } My ask is: How do I made this code working, if possible? Any ideas, suggestions, tips or tricks? If not possible, any ideas on "how do I let my web counterpart know my app was terminated"? What do I do from here? Many many thanks in advance!
0
0
471
Sep ’22
App is only able to receive VoIP when in foreground, adhoc build
Hi folks, I am developing the app which is about to receive voip push to initiate video call in wkwebkit (the call itself is being processed on the webpage and php backend, using agora engine). My issue is: app was working perfectly with sandbox, however, when moved to production build with adhoc profile, for testing purposes, I found VoIP pushes are working OK in foreground VoIP pushes are not working at all if app is in background or not started. When I checked device logs (the one I am calling to), I can't see no app activity in it, as soon as the callee app is not in foreground mode. If it is in foreground, again, all is fine and works as a charm. All the integration is properly done with CallKit: I am reporting each and every push I receive as an incoming call with the variety of statuses, no push is unhandled / unreported. Just in case, I was trying to reinstall the app multiple times, but still the issue is here. I thought it can be the distribution certificate, voip certificate, keys or provisioning profile issue - but the fact it works fine in foreground makes me quite confused. I am testing it with 2 devices, one is iPhone 12 (iOS 15.2) with SIM in it, other one is iPhone 8 (iOS 14.7) with no SIM installed. Build is performed with XCode 13.1, on M1 Mac. Not sure it is important - just trying to share as much info as I can. Any advice is highly appreciated, because I am lost a bit and have no idea of what's wrong, or what needs to be checked/where to dig at first?
2
0
2.1k
Feb ’22
Application update crashing: ok when updating adhoc, failed when updating from appstore
Hi there! I am experiencing a strange issue. New app version was released to appstore, containing new variable stored in user defaults and some minor updates. technically, we are creating new variable, which is an array of values in user defaults, and appending some items in the array. For append, we are using values which were already in place in the previous version (e.g. user_id, device_id and one more string parameter, all 3 were received from backend on 1st registration). It was (obviously) tested before release. Testing strategy: A. We were building adhoc old version (say #1) and new version (say #2), installing v1 on the devices and updating it to v2 (by simply downloading new adhoc v2 and installing it on top of v1). Then, we published v2 to appstore, and issued one more test: B. We were building same adhoc old version (say #1) installing v1 on the devices and updating it from the appstore, by B.1 in-app update functionality - following the link to appstore and B.2 just downloading most recent version from appstore. Both were fine and both are still fine. Works perfectly. Now, users are reporting that old appstore-installed v.1, updated from appstore to v.2, is crashing after update (almost immediately when it is started). Only difference we can observe is that when tested, appstore version was installed over adhoc, and now it is appstore over appstore. Was anybody ever facing the same issue? What is the difference in update process "adhoc -> appstore" versus "appstore -> appstore"? Could it be related to the fact that appstore update is cleaning up all the info from user defaults and thus we need to repeat the application reg process (get all the data again like in the first clean install)? I still have no crash reports in hand, so I am asking for some advices which can help me to solve the issue faster. Thanks everyone in advance! Andrey
1
0
547
Jul ’21
Swift 3 to 5 conversion / apple silicon MacBook
Hi all, I am in need of converting old swift 3 application to swift 5 - it is to be slightly updated & posted to Appstore. Following the guidelines, I have to install Xcode 10.1, migrate to swift 4, then I have to upgrade to more recent Xcode ver and repeat the same from swift 4 to swift 5. Given that Xcode 10.1 is not running on Big Sur, I have to either use virtual machine, or downgrade my OS to somewhat Sierra version (whatever it is exactly). And here comes my issue - as soon as I am using M1 MacBook, I can't do both. There are no VMs supporting installation of older MacOS for M1 mac (at least, none I am aware of), and also M1 mac will not run any MacOS version but Big Sur. What can I do from here? Are there any tools to migrate (apple or third-party, whatever)? In the worst case, I'm fine with just trying to build my app as is from my swift 3 source code and trying to post it to Appstore, but again, recent Xcode does not allow me to do so. Would it be an option to set up ARM Linux/Windows VM and use some command line build tools? Or, do we have any MacOS command line tools to build swift 3 project? Any help is really appreciated! Andrey
2
0
4k
Jun ’21
How do i add local database file to my appstore build?
Hello, apple developers community! I have an app which I submitted to apple review, and it was rejected because of "crash on startup". I was investigating crash logs, device console for ad-hoc build and finally came to conclusion it is failing due to inability to open a local .db file. I checked it further and found: for development build, I have "tasksolver.db" file in my bundle, and it is successfully copied into real device or any simulator for ad-hoc or appstore archive, this file is not added and is missed in the package, so app is failing on first startup with a fatal error while trying to copy it from bundle to documents folder. Was digging the internet for advices (and I am still on it), but so far I am missing the answer. I have file in my project (among other files, like a code .swift ones, on the navigator right pane), I have only 1 deployment target and the checkbox is on for the file, it is listed in development assets in target/general tab, and it is listed in build settings / deployment section. No idea on what is the difference between simulator build from Xcode and ad-hoc/appstore archive in this matter. Any help is appreciated! Cheers, Andrey
1
0
1k
Feb ’21