-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Windows 10 (phone) background music question #222
Comments
@holospeed Please see cbf3f0d However there are 2 major bugs in cordova-windows. As long as they aren't fixed, the code for windows wont be part of a release.
If you do so the app will always run in background - even without the background-mode plugin. |
Now it's clear, thank you! |
Hi, do you know if there is some workaround for this issue right now or have to wait for cordova fixes? |
@zuevalex, only manually. I want to avoid the usage of hook scripts as they aren't supported by PGB. |
What is the manual process? I have installed cordova-windows 5.0.0 which should include the resource-file copy fix. The background mode plugin does not appear in the Cordova What else am I missing? |
When I try to build my windows project i get this: |
I guess you are building your project with Visual Studio. If you are than you have to build the chosen platform not the root project. Let me explain: 1, launch visual studio 2,File 3, Open 4, Project/Solution, 4, brows to: YOUR_CORDOVA_APP/platforms/windows/ and chose the solution file (for example: CordtovaApp.windows10). when its open click on package.windows10.appxmanifest, (its must be on the right side) chose Capabilities, click on the Background Media Playback checkbox . Build the solution and it would work! |
Thank you. These last steps now have my Windows Phone running in the background. However, one of the tasks in the background is to make http calls to a REST WCF service every few minutes or so. I use the same code as used when the app is in the foreground; the $http.post angular method. When in the background it always fails. To rule out any issues WCF server side, I change it to GET requests just calling public urls like google, etc but it still fails with no exception data to go on. Resume from the background into the foreground and the calls start working again. Without changing the application so that the server is calling the client instead with push notifications, is there any way of making the $http.post angular method work in the background or is there another client-side method available? |
Hello scottlikestech, I am at the same stage now. While enabling backgroundMode for keeping the app alive, the http post fails. Thanks in advance |
Yes Oliver I solved it. The workaround was based on a flaw observed in the original .NET Mobile Framework when I was doing natives Windows Mobile apps back in 2008. I did not expect the same trick to work but it did. Before I go into the detail, you need to be aware that Microsoft recently issued a statement and are basically throwing Windows Mobile down the toilet. The plugin authors in turn will no doubt cease support for this platform, just a question of when, and then whatever app you are building with whatever plugins, you may find yourself with an app you cannot support long term. If after considering all this you still want the fix then let me know. |
I am aware WM10 is dead. I do a training project to test the virtues of Ionic/Angular4 on a personal project where I still use my Win10 mobile. |
This is assuming you have followed the above steps and have background working on Windows. I won't go over that. When making calls in Windows in background mode, it will soon keep coming back with a http status of -1. When this happens, have it run run the following code and substitute the hyperlink in the GET call with a method call on the same service as you are calling to get your app's new data in the background. Keep it as a GET call. It does not matter what this "mymethod" does, maybe it just returns the current date, just make it a different call than what the app needs to do. for (var i = 1; i <= 2; i++) { The above code makes 2 hits, 2 seconds apart. From my trial and error this works best than just one call by itself, but without being too excessive and wearing out the battery. Whether these "resuscitator calls" work or fail, you suddenly find that your next call to the actual service method you want to call in the background works, or the one after it works. Your app must cater for the intermittent issue; not all calls will work even with this fix. Once you have this working, this is not the end of the issue. You will find that after 15 minutes the app, even with background notifications working, stops running in the background after 15 minutes anyway. To prevent this from happening, have an interval that runs every 10 minutes, activated only when in the background mode, that will launch an on-screen notification to the user, which the user won't see if the app is in the background anyway but keeps the app alive. DO NOT do this as an actual screen notification that will pop up to the user on their phone from background mode; it will annoy the user and drain the battery. |
scottlikestech, thank you very much for your help! I appreciate! |
The plugin working well when I launch (debug) the app via cable from Visual Studio, but when I start the app directly from the phone the plugin donent working at all. Is someone has any idea what could be the problem ?
The text was updated successfully, but these errors were encountered: