Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 906 Bytes

README.md

File metadata and controls

34 lines (23 loc) · 906 Bytes

iOS Silent Bypass

iOS Silent Bypass is a library that allows you to play audio context even if the user has the action button/silent switch on. You'll need to wait for an user interaction to check if the audio context is allowed.

Usage

npm install @activetheory/ios-silent-bypass
import SilentBypass from '@activetheory/ios-silent-bypass';

function isIOS() {
  return navigator.userAgent.includes('iPhone') || navigator.userAgent.includes('iPad');
}

let silentBypass;

if (isIOS()) {
  silentBypass = new SilentBypass();
}

// after the library is initialized, you can check if the audio context is allowed
console.log(silentBypass?.allowed);

// if you want to remove the event listeners after the audio context is allowed, you can call the destroy method
silentBypass?.destroy();

License

MIT