Hopefully make alerts not stop music on iOS (#59)

This commit is contained in:
Skylar Ittner 2023-07-14 00:02:46 -06:00
parent c6b4ed81d6
commit 5f335cdef4
3 changed files with 51 additions and 0 deletions

View File

@ -51,8 +51,10 @@
<preference name="AutoHideSplashScreen" value="true" />
<preference name="FadeSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="MediaPlaybackAllowsAirPlay" value="false"/>
<hook src="scripts/npm_prepare.sh" type="before_prepare" />
<hook src="scripts/remove_powermanagement.sh" type="before_prepare" />
<hook src="scripts/fix_ios_audio.sh" type="before_compile" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="DisallowOverscroll" value="true" />
<allow-intent href="itms:*" />

5
scripts/fix_ios_audio.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "Replacing AppDelegate.m to fix AVAudioSession.Category..."
cp src/ios/AppDelegate.m platforms/ios/PackageHelper/Classes/AppDelegate.m

44
src/ios/AppDelegate.m Normal file
View File

@ -0,0 +1,44 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
//
// AppDelegate.m
// PackageHelper
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import "AppDelegate.h"
#import "MainViewController.h"
#import <AVFoundation/AVFoundation.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.viewController = [[MainViewController alloc] init];
//set audio category to stop app interrupting music
NSError *setCategoryError = nil;
BOOL success = [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: &setCategoryError];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end