-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
fix: entitlement requirement issue on iOS devices #900
base: minor
Are you sure you want to change the base?
Conversation
Thanks @pedromassango . I'd like to test this against a minimal reproduction project, but I actually never saw a valid issue submitted for this and was unclear whether it was a build error or a runtime error. How can I test/reproduce this? |
I will let you know once I have a reproducible code |
I see the same issue for iOS in my app - it is not a critical error and everything seems to be working well, but I see numerous of such messages in the log:
|
Yes, since the message says "Ignoring setPlaybackState", I would have expected it to be harmless, so it's surprising it turns out this can be critical and prevent audio from playing. |
Yes, but I agree that
should be executed on MacOS only. As the docs say:
|
Yep I definitely agree with that. I think I have a habit of only looking in the sidebar of the documentation which says it is available on these specific versions of iOS and macOS, although the body clearly overrides that information. I guess I would just like to be able to reproduce this myself before merging, and I'm not sure exactly what the observed behaviour is or how to reproduce it yet. |
I have the same problem, but my audio works. I don't know if problems with the remoteControlFunctionality can result. |
Just waiting for @pedromassango to provide instructions on how to reproduce the problem of audio not playing. @csacchetti can you maybe test this PR and confirm whether it solves your issue? |
After testing this PR I'm getting:
Looks like this is a Swift construct, and for Objective-C you need to use one of the https://epir.at/2019/10/30/api-availability-and-target-conditionals/ |
@ryanheise [NowPlaying] [MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform Here is the link to the tutorial: You can download repository here: |
Did you test the pr? |
I think this PR needs to use Before I can merge this, I think we should also ensure that the change works on both macOS and iOS (i.e. the controls appear in the control center in both cases correctly after play/pause). Edit: from my tests, this seems to make iOS stop working, in that the controls no longer appear on the lock screen while playing. Can anyone confirm? |
Some more insight on the original issue: I tried to use the version by @pedromassango, but upon compiling I got the following errors:
Output of flutter doctor:
|
Yes, that is a problem with this PR, and I have mentioned in my previous comment what needs to be done to fix this before I can merge this:
|
Hey, so sorry fo the late reply here. After a while I was able to find out that the issue is not related with this change. I will go ahead and close this PR as the problem I was facing as nothing to do with it! Sorry y’all! |
It is true that the audio is still heard and everything works, but I think it is better to remove this message in the console: [NowPlaying] [MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform |
Yes I agree something should be done about that, but has anyone tested the changes @pedromassango proposed but using the |
Reopening. |
Ok then, honestly I don't have much experience with native iOS 🐒 I will try to test this and give a feedback asap |
Has anyone tried this solution and tested on both iOS and macOS? |
Any updates on this? I ran into this issue (not sure if it's an entitlement or provisioning issue that I'm having) and I can't do background playback, although this plugin is working great for me on android :) FYI: When I try to build this version of the source code on iOS I do get the same error:
FYI I got this to work on iOS by adding
to my Info.plist. I guess I missewd that part of the documentation! Sorry! I still see the error though but it doesn't seem to matter. The play / pause buttons still work from the UI |
Regarding the |
I tried to read some iOS documentation and it seems to me that the problem might be related to: MPNowPlayingInfoCenter.default().playbackState In fact, the solution proposed by the forums is this; https://developer.apple.com/forums/thread/678108 So if you don't have macOS enabled in xCode you don't have the com.apple.mediaremote.set-playback-state entitlements for the macOS playback state, and so if the Audio Service plugin also supports macOS it is likely to use MPNowPlayingInfoCenter.default().playbackState and thus create the problem. I have no interest in enabling MacOs for my app (is only for iOS and Android) so I can't verify this but I think @ryanheise could enable this command only if MacOs is enabled and instead disable it if MacOs is not enabled This explains why in spite of this problem in iOS everything works correctly. I hope it helps |
That is why I referred readers to #900 (comment) which explains how to correctly "compile out" this code when it is not needed on iOS. The main reason that this PR hasn't been merged yet is that it does not use the correct preprocessing instructions to do this. The secondary reason is that it needs to be tested and verified to ensure that people no longer get the warning/ |
@ryanheise I honestly think that this is not the fix for the problem I stated in the original post. I would suggest to close this! |
I am getting this same error, everything is working except for custom click() in audio_service. In Android I am able to do custom action based on the headset clicks, but not on iOS at all. For iOS the headset does the default actions instead. |
I saw this comment on one of Apple's forums:
Can this be the cause of the issue? I don't have CarPlay entitlement for my app, and I do see this warning message. I am applying for CarPlay entitlement. I will test when I get approved. |
I did a quick test of the proposed changes in this PR and confirmed the way @ryanheise proposes to fix it - works. NSLog(@"### ENSURE THIS IS UPDATED CODE 0.18.12 Darwin");
#if TARGET_OS_OSX
if (@available(iOS 13.0, macOS 10.12.2, *)) {
center.playbackState = playing ? MPNowPlayingPlaybackStatePlaying : MPNowPlayingPlaybackStatePaused;
}
#endif And then logs are clear when testing on iOS 2023-09-27 13:17:08.334248+0300 Sudor Staging[1347:69326] flutter: AUDIO MANAGER AUDIOSESSION CALL 8
flutter: AUDIO MANAGER AUDIOSESSION CALL 8
2023-09-27 13:17:08.439089+0300 Sudor Staging[1347:69278] ### ENSURE THIS IS UPDATED CODE 0.18.12 iOS
2023-09-27 13:17:08.444080+0300 Sudor Staging[1347:69278] ### ENSURE THIS IS UPDATED CODE 0.18.12 iOS
2023-09-27 13:17:08.457794+0300 Sudor Staging[1347:69278] ### ENSURE THIS IS UPDATED CODE 0.18.12 iOS
2023-09-27 13:17:08.644577+0300 Sudor Staging[1347:69278] ### ENSURE THIS IS UPDATED CODE 0.18.12 iOS Important - not only
I'm struggling with how to test it with macOS, but I will manage later this week, I hope. |
There is an iOS Release builds where the audio won't play due to the error below:
[NowPlaying] [MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform
Closed issue that this PR fixes.
Pre-launch Checklist
minor
branch OR my change is breaking and lands inmajor
branch.pubspec.yaml
according to the [pub versioning philosophy].* DESCRIPTION OF YOUR CHANGE (@your-git-username)
).///
).dart analyze
.dart format
.flutter test
and all tests are passing.