Open gondp opened 5 years ago
I'm experiencing this too after testing the application on 12.2
Can confirm, having the same problem.
it looks like it's because the plugin is using a private api which is no longer allowed: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/293
is there a solution to use background mode in iOS 12.2?
@CodingAnonymous As of right now, no. My team is now actively moving away from Ionic and Cordova because of this issue. We've been meaning to start going fully native for awhile, but this issue cemented our path.
@BuddyLReno The issue on Ionic’s end has been fixed in latest webview plugin. Also, We don’t maintain this background plugin
We are experiencing the same problem. We cannot just let our app crash on the new version of the system. Please let us know if this issue can be fixed soon (@katzer ). Or any possible solutions are welcome.
@mlynch yes but the solution doesn't restore original functionality.
Without the background mode working as before, we're unable to save the progress through a users audio. Our app plays 40+ minute podcasts so it's important so save the progress about every ten seconds while the phone is locked.
Same problem. To fix I went to the plugin in Xcode. Removing lines APPBackgroundMode.m:266 & 267: [obj setValue:[NSNumber numberWithBool:YES] <--- remove! forKey:[APPBackgroundMode wkProperty]]; <--- remove!
I was able to get a build working. Haven't tested beyond that.
@iowayankee Can the plugin still work properly after your change?
Can confirm, having the same problem.
Encountered the same issue.Thanks @iowayankee! Your fix works. However, I still need to check the impact of the fix in background mode...
Try in file src\ios\APPBackgroundMode.m replace following lines
+ (NSString*) wkProperty
{
NSString* str = @"X2Fsd2F5c1J1bnNBdEZvcmVncm91bmRQcmlvcml0eQ==";
NSData* data = [[NSData alloc] initWithBase64EncodedString:str options:0];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
with
+ (NSString*) wkProperty
{
NSString* str = @"YWx3YXlzUnVuc0F0Rm9yZWdyb3VuZFByaW9yaXR5";
NSData* data = [[NSData alloc] initWithBase64EncodedString:str options:0];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
Try in file src\ios\APPBackgroundMode.m replace following lines
+ (NSString*) wkProperty { NSString* str = @"X2Fsd2F5c1J1bnNBdEZvcmVncm91bmRQcmlvcml0eQ=="; NSData* data = [[NSData alloc] initWithBase64EncodedString:str options:0]; return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; }
with
+ (NSString*) wkProperty { NSString* str = @"YWx3YXlzUnVuc0F0Rm9yZWdyb3VuZFByaW9yaXR5"; NSData* data = [[NSData alloc] initWithBase64EncodedString:str options:0]; return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; }
This actually worked for me.
Basically what you did was changing the base64 encoded string from: _alwaysRunsAtForegroundPriority to alwaysRunsAtForegroundPriority
Same problem. To fix I went to the plugin in Xcode. Removing lines APPBackgroundMode.m:266 & 267: [obj setValue:[NSNumber numberWithBool:YES] <--- remove! forKey:[APPBackgroundMode wkProperty]]; <--- remove!
I was able to get a build working. Haven't tested beyond that.
Wow! works good
@BuddyLReno I submitted a PR to the Ionic Webview repository that should restore the background functionality, is backward compatible and has no issues with app store submissions that I have seen as long as you have valid background capability set and actual valid activity when in background (as it was previously). Give it a try if you like.
@ghenry22 can you link your PR?
link for @ghenry22's PR https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/343
Can someone confirm if it worked?
@gpartida It worked?
@silvanavlima it passed our QA on testflight, we havent submitted the app for public release but we should be doing this soon.
@gpartida but the background mode is working as before? or lost functionality?
For my use case it works as before. I think this fix is about using the new name for an API which is still private not tapping into a more legit way to handle background functionality, so this is still bad and could easily just disappear one day, but it fixes my app from being completely broken today.
@BuddyLReno the background mode plugin does not work? my audios stop when it's in the background. Is it the same with you?
+1
+1
I did what seems to be quickest way to get it working.
It just doesn't make sense that it also works on iOS 11.4. I tested in a simulator. Does anyone know why it works in earlier versions of iOS?
Has anyone got a fix for this not working on iOS 12?
@BuddyLReno The issue on Ionic’s end has been fixed in latest webview plugin. Also, We don’t maintain this background plugin
So maybe you have suggestion how we can make app runs backgroud
Same problem. To fix I went to the plugin in Xcode. Removing lines APPBackgroundMode.m:266 & 267: [obj setValue:[NSNumber numberWithBool:YES] <--- remove! forKey:[APPBackgroundMode wkProperty]]; <--- remove!
I was able to get a build working. Haven't tested beyond that.
thank @iowayankee , your save my time. this worked for me.
@iowayankee sir tried but got same error again ?
None of the solutions worked for me. I had to uninstall backgroundMode completely as, nor condition based on this.platform.is('android') works.
@BuddyLReno The issue on Ionic’s end has been fixed in latest webview plugin. Also, We don’t maintain this background plugin
@mlynch I understand that nobody is maintaining this plugin anymore, but I've tried with both cordova-plugin-ionic-webview
2.5.1
(because we actually still need to support iOS 10 with our app) as well as the latest 4.1.1
release, but I still can't get this plugin to work on our iOS 12.3 iPad. Not sure about 12.2 because I don't have any devices with that version, but it does still work on our iOS 12.0 iPad.
From your message above, I'm assuming the latest version of cordova-plugin-background-mode
should work if I use a release of cordova-plugin-ionic-webview
that provides the required API methods. Or am I missing something here? There are so many forks of this plugin, I'm honestly not sure where to start..
edit: alrighty, got it working with the latest of both the 2.x
and 4.x
releases of cordova-ionic-webview
by switching over to @iowayankee's fork over at https://github.com/iowayankee/cordova-plugin-background-mode
I'm happy, my boss is happy, and life is good again. (:
hi team anybody fixed above issue in iOS 12.2?
@ZaLiTHkA Have you actually tested the background activity? this fix fixes the app crash, but all http requests that are triggered by location change (which is working properly) when the app is in the background fail:
{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":null,"ok":false,"name":"HttpErrorResponse","message":"Http failure response for (unknown url): 0 Unknown Error","error":{"isTrusted":true}}
I have tried updating cordova-plugin-ionic-webview
to 2.5.1
and it leads to same error. Same code works for iOS 12.1.
Any leads?
@edento, if you have a look at the edit to my previous message, you might notice I've actually switched to a fork of a fork of this project..
this is just one of the unfortunate side-effects of dealing with Cordova plugins in general, most of them tend to either get ignored for long periods of time or abandoned completely, so when one dev with good intentions forks the project to fix something, their PR never gets back to the original. and so this one has (currently) 752 forks. O.o
that said, I'm not sure about handling things like HTTP calls while the app is in the background. in our case, we have a socket connection with observables that give me data when the data source updates, so it's not an action I need to explicitly call. I do know that the webview engine does limit the frequency of function calls made in background mode, but I'm not sure if it affects them in any other ways.
if you're trying to explicitly fetch data from a remote source while your app is in the background, perhaps you might benefit from moving that "fetch" logic into a service worker? haven't played with them much myself, but as I understand these are specifically designed to operate "in the background" behind the main app thread, so they aren't restricted by the same means.
beyond that, I'm not really sure what else to suggest.
@ZaLiTHkA You're right, I missed the fork link. Anyway I tested it and unfortunately its not working for my case. I want to make a post request with the new user location to do some server calculation, but the request never makes it to the server =\
Thank you for the response anyway :)
@ZaLiTHkA well, eventually changing the HTTP package resolved this issue. Changed angulars package HttpClient
(@angular/common/http) to @ionic-native/http/ngx.
@edento: sir what is realtion of above issue with HttpClient plz explain me.
@ZaLiTHkA: sir are u fixed issue after change version of Crdova-plugin-ionic-webview
@edento: sir what is realtion of above issue with HttpClient plz explain me.
I don't think it relates to this issue specifically, that's just the module Eden was trying to use while their app was in background mode..
@ZaLiTHkA: sir are u fixed issue after change version of Crdova-plugin-ionic-webview
nope, not by changing the webview plugin (doing that made no difference), I "fixed" mine by changing to this fork of the background mode plugin.
note: I see there was actually an update to this project recently, so have you tried using version 0.7.3
yet?
@ZaLiTHkA : ok sir I tried above mentioned fork and tell me one more thing sir why its not working in IOS 10 version also.
@iowayankee and @sergey-mohov : sir i tried ur solution but not worked for me?
After updating to iOS 12.2 the application ends just run. If I delete the plugin it works correctly
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _alwaysRunsAtForegroundPriority.'