-
Notifications
You must be signed in to change notification settings - Fork 261
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
Prevent crash when using a NativeScript app (for alternate icon name) #116
Conversation
After showing a Toast my app would crash when using [this method](https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname). I have very little experience in Swift so I don't know why the `rootViewController` getter needs to be hijacked by this pod, but to make it work for my case I'd really love to have this code merged.
Can you share the way to reproduce the crash? |
Good question. I just tried reproducing it with your demo and sadly for me I can't. If I add a breakpoint to the rootViewController getter I notice that your demo will hit that method when a Toast is shown, but not when it's used inside a NativeScript app (that's my usecase). Funny thing is that when the method to change the icon runs, both a native Swift app and a NativeScript app hit the aforementioned getter. But in the NativeScript case we need the fallback this PR was created for. I hope that fallback doesn't bother you as it's quite similar to what you have until recently. If you're not going to merge it I'm afraid I have to use my own fork. Btw, the screenshot below is proof that your code is compatible with the icon change feature of iOS 10.3 (unless it runs in a NativeScript app (and perhaps Cordova and React Native as well)): Thanks for considering anyway and keep up the great work! |
@EddyVerbruggen I would definitely love to patch a bug if it exists. But changing |
@devxoul I can reproduce it with a NativeScript app, not with a Swift app. Would that be of help? |
Hmm. Does NativeScript app have different window hierarchy from native Swift app? |
@EddyVerbruggen you seem to work at NativeScript. I've done those install steps:
I've done those cocoapods setup steps:
Now I need to figure out how to call Toaster from javascript. I'll be back once I figure it out. |
@Coeur Much appreciated! For your last comment, perhaps this can be of help: https://github.com/EddyVerbruggen/nativescript-toast/blob/master/toast.ios.js |
[edit] OK, next:
(nice thing is that changes in .js are applied on the fly) But with current devxoul/Toaster:master branch, we get:
|
@Coeur If that's undefined, it means the Pod isn't actually loaded. Your steps seem OK though so I'm curious. Can you share your project? Otherwise I'll have to retrace your steps and I may end up doing it slightly differently. |
I've fixed the issue by using your fork, like that: https://github.com/Coeur/nativescript-toaster/commit/1e6d422d3902a4c1ed4e590ce625b78fe98484c5 [edit] |
@Coeur The missing So to reiterate, showing a Toast works, but if you would use this method the app would crash. If you did not show a Toast beforehand, the app would not crash. |
Let's address the Objective-C compatibility in a pull request of its own: #147. |
@EddyVerbruggen I've added a call to Could you provide a sample MCVE of the crash issue? Maybe a simple fork of https://github.com/Coeur/nativescript-toaster/ ? |
@EddyVerbruggen As I can't reproduce the issue that you're facing, I'll close this PR for now. |
After showing a Toast my app would crash when using this method.
I have very little experience in Swift so I don't know why the
rootViewController
getter needs to be hijacked by this pod, but to make it work for my case I'd really love to have this code merged.