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

No working from iOS 12.2 #419

Open
gondp opened this issue Feb 2, 2019 · 42 comments
Open

No working from iOS 12.2 #419

gondp opened this issue Feb 2, 2019 · 42 comments

Comments

@gondp
Copy link

gondp commented Feb 2, 2019

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.'

@Baadier-Sydow
Copy link

I'm experiencing this too after testing the application on 12.2

@mciekurs2
Copy link

Can confirm, having the same problem.

@BuddyLReno
Copy link

it looks like it's because the plugin is using a private api which is no longer allowed: ionic-team/cordova-plugin-ionic-webview#293

@T3chTobi
Copy link

is there a solution to use background mode in iOS 12.2?

@BuddyLReno
Copy link

@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.

@mlynch
Copy link

mlynch commented Feb 21, 2019

@BuddyLReno The issue on Ionic’s end has been fixed in latest webview plugin. Also, We don’t maintain this background plugin

@Hao-Axon
Copy link

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.

@BuddyLReno
Copy link

@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.

@iowayankee
Copy link

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.

@Hao-Axon
Copy link

@iowayankee Can the plugin still work properly after your change?

@KinG-InFeT
Copy link

Can confirm, having the same problem.

@wynngd
Copy link

wynngd commented Mar 18, 2019

Encountered the same issue.Thanks @iowayankee! Your fix works. However, I still need to check the impact of the fix in background mode...

@sergey-mohov
Copy link

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];
}

@edwardbrosens
Copy link

edwardbrosens commented Mar 25, 2019

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

@AthiraWD
Copy link

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

asharaky added a commit to asharaky/cordova-plugin-background-mode that referenced this issue Apr 1, 2019
TheBosZ added a commit to TheBosZ/cordova-plugin-background-mode that referenced this issue Apr 1, 2019
tessarini added a commit to nitryxgit/cordova-plugin-background-mode that referenced this issue Apr 2, 2019
@ghenry22
Copy link

ghenry22 commented Apr 10, 2019

@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.

schoenkaft added a commit to schoenkaft/cordova-plugin-background-mode that referenced this issue Apr 10, 2019
Note that this was a wildly used hack, which stopped working. This is a quick fix, but it's not future proof.

See: katzer#419
See: ionic-team/cordova-plugin-ionic-webview#293
schoenkaft added a commit to schoenkaft/cordova-plugin-background-mode that referenced this issue Apr 10, 2019
Note that this was a wildly used hack, which stopped working. This is a quick fix, but it's not future proof.

See: katzer#419
See: ionic-team/cordova-plugin-ionic-webview#293
@donkeytronkilla
Copy link

@ghenry22 can you link your PR?

@BorntraegerMarc
Copy link

BorntraegerMarc commented Apr 11, 2019

@silvanavlima
Copy link

Can someone confirm if it worked?

@silvanavlima
Copy link

@gpartida It worked?

@donkeytronkilla
Copy link

@silvanavlima it passed our QA on testflight, we havent submitted the app for public release but we should be doing this soon.

@silvanavlima
Copy link

@gpartida but the background mode is working as before? or lost functionality?

@donkeytronkilla
Copy link

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.

@silvanavlima
Copy link

@BuddyLReno the background mode plugin does not work? my audios stop when it's in the background. Is it the same with you?

@KinG-InFeT
Copy link

+1

1 similar comment
@joaowebdec
Copy link

+1

rodrigovrm added a commit to refurbify/cordova-plugin-background-mode that referenced this issue Apr 24, 2019
Fixes the hack for the private setting alwaysRunsAtForegroundPriority

see: katzer#419
see: ionic-team/cordova-plugin-ionic-webview#293
@rodrigovrm
Copy link

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?

@sts-ryan-holton
Copy link

Has anyone got a fix for this not working on iOS 12?

@GloomyStranger
Copy link

@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

@IwonGunawan
Copy link

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.

@kapilSoni101
Copy link

@iowayankee sir tried but got same error again ?

@16am
Copy link

16am commented May 29, 2019

None of the solutions worked for me.
I had to uninstall backgroundMode completely as, nor condition based on this.platform.is('android') works.

@ZaLiTHkA
Copy link

ZaLiTHkA commented Jul 17, 2019

@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. (:

@kapilSoni101
Copy link

hi team
anybody fixed above issue in iOS 12.2?

@edento
Copy link

edento commented Aug 24, 2019

@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?

@ZaLiTHkA
Copy link

ZaLiTHkA commented Aug 24, 2019

@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.

@edento
Copy link

edento commented Aug 24, 2019

@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 :)

@edento
Copy link

edento commented Aug 24, 2019

@ZaLiTHkA well, eventually changing the HTTP package resolved this issue. Changed angulars package HttpClient (@angular/common/http) to @ionic-native/http/ngx.

@kapilSoni101
Copy link

kapilSoni101 commented Aug 25, 2019

@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

@ZaLiTHkA
Copy link

@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?

@kapilSoni101
Copy link

kapilSoni101 commented Aug 25, 2019

@ZaLiTHkA : ok sir I tried above mentioned fork and tell me one more thing sir why its not working in IOS 10 version also.

@kapilSoni101
Copy link

kapilSoni101 commented Aug 26, 2019

@iowayankee and @sergey-mohov : sir i tried ur solution but not worked for me?

lucas-t5 pushed a commit to lucas-t5/cordova-plugin-background-mode that referenced this issue Oct 3, 2019
agriboss added a commit to agriboss/cordova-plugin-background-mode that referenced this issue Oct 8, 2020
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