AppLovin / AppLovin-MAX-SDK-iOS

84 stars 69 forks source link

Audio is disabled in app, updating to 10.3.6 doesn't help #40

Closed Shchvova closed 1 year ago

Shchvova commented 2 years ago

After playing interstitial or rewarded app audio session is broken in the app, unable to make sounds.

Keane81 commented 2 years ago

Also interesting in that issue, any updates there?

ryanbalieiro commented 2 years ago

Facing exactly the same issue here.

After the ad is closed, I get the following error log:

"[avas] AVAudioSession_iOS.mm:1243 Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session."

The app doesn't play any sound anymore unless you send the app to the background and switch back to it.


[EDIT] Just found a quick workaround to avoid this issue that worked for me.

Before showing an ad, change the AvAudioSession category to AVAudioSessionCategoryAmbient.

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
[self.ad showAd];

After the ad is complete, use the didHideAd() delegate method to change the AvAudioSession category back to the original value. I'm using AVAudioSessionCategoryPlayback.

- (void)didHideAd:(MAAd *)ad
{
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
}
cihadturhan commented 2 years ago

Facing exactly the same issue here.

After the ad is closed, I get the following error log:

"[avas] AVAudioSession_iOS.mm:1243 Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session."

The app doesn't play any sound anymore unless you send the app to the background and switch back to it.

[EDIT] Just found a quick workaround to avoid this issue that worked for me.

Before showing an ad, change the AvAudioSession category to AVAudioSessionCategoryAmbient.

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
[self.ad showAd];

After the ad is complete, use the didHideAd() delegate method to change the AvAudioSession category back to the original value. I'm using AVAudioSessionCategoryPlayback.

- (void)didHideAd:(MAAd *)ad
{
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
}

Thank you! I've been searching this for over a month. I use ironsource mediation with applovin so it was hard to know. Finally someone figured out the actual problem.

fredriksthlm commented 1 year ago

For me this seems to be an issue with Webview, that it loses the audio every time an ad activity is shown. The audio for the webview will then be permanently off when the ad is dismissed.

If you minimize the app and then reopen it the audio is back.

I do not have the same issue with the mediated Pangle ads, only Applovin ads. (And only real ads. The test ads always work perfectly fine..)

NanaAmoah commented 1 year ago

We released AppLovin SDK v11.6.1 with a fix for the issue. You can enable the fix using the steps in these docs after upgrading to this version. @Shchvova @Keane81 @ryanbalieiro @cihadturhan @fredriksthlm

fredriksthlm commented 1 year ago

@NanaAmoah thank you for this. I have discussed this with Thomas a bit during the last weeks. Will you document this "fix" in your official documentation (iOS, Unity, Cordova) anywhere?

Can you show exactly how the code is supposed to be implemented within this file: https://github.com/AppLovin/AppLovin-MAX-Cordova/blob/master/plugin/src/ios/AppLovinMAX.m

Since we cannot verify in the log, or anywhere else, if we actually managed to set it correctly?

keasukei commented 1 year ago

@NanaAmoah still have this problem, i'm using 11.8.0,

keasukei commented 1 year ago

@NanaAmoah after using MaxSdk.SetExtraParameter("return_audio_focus", "true"); The frequency of game mute has decreased,but still has this problem

fredriksthlm commented 1 year ago

@keasukei Yes this is still an issue for everyone. You can follow it here: https://github.com/AppLovin/AppLovin-MAX-SDK-iOS/issues/187