In my iOS AU host application, I am using AVAudioUnitComponentManager.components method to retrieve the list of available Audio Units. It works as expected most of the time. However sometimes it returns only Audio Units created by Apple, and none of the third-party Audio Units that are installed on the device. The interesting thing is that, if after I encounter this issue in my app I go to GarageBand and open the Audio Unit list there then when I return to my app, all the third-party AUs are present. So I am wondering maybe some other initialization should be done before calling AVAudioUnitComponentManager.components method which GarageBand is doing and I also should do in my app.
Any suggestions?
As is turned out, the problem was happening because my app did not have an entitlements file with the “Inter-App Audio” capability key. After adding this capability to my project target in xcode the problem was fixed.
Related
I am using flutter_local_notifications 9.4.1 in my flutter mobile application
I am deploying successfully to Android and iOS 14.2
My use case is simple - to provide a local notification with a sound when a specific task has completed.
Android - everything works fine - my mp3 sound plays when the notification appears just as I want. Perfect.
iOS - I have everything working except for sound. I have added a custom sound (a CAF file converted from a .AIF file, using the Apple recommended procedure ... afconvert). I added the sound file to the Flutter project the correct way - by using XCode to include it into the top level folder with the target ticked. In my flutter code, I already have the modification to the appDelegate.swift, and in the IOSNotificationDetails I have ensured that presentSound is true and presentAlert is true. I am also specifying sound: 'mysound.caf'. But actually even if I don't specify a custom sound, according to the documentation, the default sound will be used. But no sound occurs, default or otherwise.
On the iPhone device, I have checked silent mode is off, I have checked the app permissions - everything set as it should be - sound is enabled, notifications are enabled. I have even copied the CAF file manually to the iOS device to be sure it plays and that I can hear it! I have no build errors or run-time errors. So I must be missing something.
I don't know of a way to check that the sound file is actually deployed to the device - is this possible?
Is there something in the setup or deployment process I have missed? I have not posted code up because I have spent hours comparing my code to the documentation and finding no differences. I am hoping someone has experienced this and found an undocumented step.
Just to give some context, there is an iOS app I'm building (in Xamarin) that requires the ability to fetch files (in an automatic way without having the user to navigate to the files and select them manually) that are stored on External Storage Devices (USB Sticks), and are connected (paired) to an iPhone/iPad.
Users connect a lighting cable to the iOS Devices, and plug their USB Sticks into this lighting cable. Here is an example of the cable that end users use to pair the USB Sticks with their iPhone/iPad, and the app then auto fetches these files from the USB Storage Devices.
The app then performs 2 functions:
It listens to notifications, for when a usb stick is paired with the iOS Device.
When it receives this notification, it then proceeds with querying the files on the USB Stick, and reads and processes the files. The app reads these files automatically and the user does not need to manually select these files
I've tried using External Accessory Framework, however that's only suitable for devices that you register with the MFi program.
https://developer.apple.com/documentation/externalaccessory
Notifications Center never seems to work (the Notifications that handle when a Device gets Connected and Disconnected, the delegates never get called), and I've tried using the Microsoft Helpers.
https://learn.microsoft.com/en-us/dotnet/api/externalaccessory.eaaccessorymanager.notifications.observedidconnect?view=xamarin-ios-sdk-12
I've also tried some 3rd party libraries, but haven't found anything useful.
It doesn't look Apple has any Api Available to auto query and read the files, without having to use a DocumentPickerController. I know this is because of the App Sandbox, and I cannot directly access the Removable Storage Devices.
Now for my questions:
Are there any 3rd party libraries anybody can recommend, that can help achieve most of the heavy lifting for this task? I'd prefer a library that's compatible with Xamarin, however if it's a native library (Swift or Objective-C Library, Cocoapods) I'm sure there is a binding I can use on nuget.
Does anybody have any snippets, or documentation, or can point me in the right direction here (Please feel free to post Swift, or Objective-c solutions here if you like)? Where should I look, which Apple Framework (iOS SDK) is most suitable to deal with this situation. And to summarise, is what I'm asking for at all possible on iOS, without having to jailbreak, or get around the App Sandbox?
Update
So I've tried the solution that #Saamer suggested:
Detect if USB is connected to iPhone device
Here is an example I wrote just to verify if the callback gets invoked, and the app can detect if a usb is plugged in.
CFNotificationCenter.Darwin.AddObserver("com.apple.mobile.lockdown.host_attached", null, (e, s) =>
{
MainThread.BeginInvokeOnMainThread(async () =>
{
var picker = await Xamarin.Essentials.FilePicker.PickAsync();
});
}, CFNotificationSuspensionBehavior.DeliverImmediately);
A file picker should immediately get invoked, and open up, once I plug the USB in, however this doesn't happen.
I'm happy for a solution right now which opens up a file picker, when the user plugs in a USB Device, and navigates to the root directory to start off with. So when the File Picker opens up the user should see this. Then they can select the files they want to transfer into the app.
I thought you needed to jailbreak but it seems unlikely, a solution is possible for <iOS 12
CFNotificationCenter's AddObserver seems to be usable for detecting when a device is connected using host attached and detached as shown here
Or if you don’t submit it to the App Store, you can use this
According to the Apple Docs
You can use the Files app and other supported apps to access files stored on external devices, such as USB drives and SD cards, connected to your iPhone.
Essentially you have to make your a "supported app". I have downloaded a free app called "Clockology" that I recommend downloading and playing with, which allows users to see data within the app as you can see below:
You generally use UIDocumentPickerViewController along with the right uttype to get the files from the Files apps or iCloud Drive, and you require activating the Key-value storage and iCloud Documents from iCloud entitlements capability. There's a lot of tutorials on UIDocumentPickerViewController usage, but you specifically want the capabilities that became available from iOS 13 onwards
This video from WWDC is the best example of getting to where you want. I also didn't find any 3rd party libraries that can help with this
——————-
Edit: If the app does not need to be distributed through TestFlight or the App Store, you can use IOKit and distribute through AppCenter, as long as you have the UDIDs of all the devices you need the app installed on (up to 100?)
Is there a way inside an iOS Swift app of mine, to access the sound files I already have available in my itunes library on the same device?
Browsing the net I came accross something called File-Sharing and the UIFileSharingEnabled key, but that does not seem to be quite what I am looking for.
The files? I’m not sure.. if so only those you downloaded or bought on iTunes. For access to Apple Music you probably want to look into MusicKit.
However, there’s a way to get MediaItems via MPMediaPickerController (docs)
I am making a simple sprite kit game that needs an audio input from the microphone for voice commands. I have already created a simple game and I have already created a separate app that if you speak a word it detects and it displays on the screen using cmu-sphinx/pocketsphinx (http://cmusphinx.sourceforge.net/).
I was using Novocaine (https://github.com/alexbw/novocaine) because I have used this library numerous times and had great success with it in other projects in the past, but whenever I initiate the Novocaine object in the game, my app crashes with an exception.
So I figured that since I was using a wrapper library it must have been some deprecated functions that were not supported any more, so I did some more research. I came across Apple's demo app AurioTouch (https://developer.apple.com/library/ios/samplecode/aurioTouch/Introduction/Intro.html). After playing around with that sample app, I was able to narrow down the classes that I needed to get the raw input values, which was primarily the AudioController class. So I imported over the AudioController class and its necessary components and was able to build it. Fortunately, the example had proper exception handling so I was able to see where it was failing. The exception was caused by this line:
AudioUnitInitialize(_rioUnit)
I was beginning to suspect that trying to access the microphone in a SpriteKit/SceneKit environment was causing the issue. I've also tried the same steps mentioned above in brand new SpriteKit and SceneKit projects and did not resolve the issue. So I am wondering if it is anyway possible for you to give real time microphone input within a SpriteKit/SceneKit project.
There is a setting in the iOS Settings app under Privacy : Microphone, where you have to switch on permission for an app to use the device's microphone. The AVAudioSession requestRecordPermission API can help check this permission setting.
There are also some AVAudioSession categories that should be set and activated to use the microphone. The use of SpriteKit and SceneKit does not interfere with these settings.
In iOS 10 Apple is extending the scope of privacy control. You have to declare in Info.plist file access of any private data.
Goto Info.Plist file and added the privacy key according to your requirement.
Microphone :
Key : Privacy - Microphone Usage Description
Value : $(PRODUCT_NAME) allow microphone use to give audio input for voice commands.
I have a Blackberry application. This application downloads then plays a video file.
I am trying to switch to a model where the video is bundled in with the application inside the res/media/ folder.
The only chane in the application was making the input stream that gets displayed on the Player come from the file in res/media/ rather than the file stored in the media storage of the device. I did not change anything else related to any View components.
But now when I try to start the application I get an error dialog that says:
"Error starting [myAppName]: Class 'net.rim.device.api.ui.component.ButtonField' not found."
Since I did not change anything related to a ButtonField why would I be getting this error now that the video is bundled in?
By adding the video file it made it so that my project had many additional files that needed to be signed. They all get signed correctly. But when the application is launching I get messages in the console that say something like
CMM: [MyAppName] no sig from 0x33
which I did not get when the video wasn't bundled with the resources. Is this somehow related to my problems?
My application does not even get a chance to begin. I have log statements at the beginning that I never see. It fails before it even begins.
The error you are receiving indicates that your app is too large. In my experience there is a practical limit of around 5MB for an application, any more than this and you will run into these strange 'class not found' errors.
Try adding a smaller video file to see whether the problem goes away.
CMM: [MyAppName] no sig from 0x33 means that [MyAppName] has not been signed with a code signing key identified by 0x33. This key is only available to applications produced by RIM, and can be ignored by your application. Dont worry about it.we see it all the time.
I suspect you are trying to test your app in the emulator. try your app in device and see what happens.
Also i dont think its a good idea bundling a video in your app as it will increase the size of the app significantly. You can download the app on startup and save it in filesystem. There is a limit of about 15 MB for a blackberry app. check this http://supportforums.blackberry.com/t5/Testing-and-Deployment/The-maximum-size-of-a-BlackBerry-smartphone-application/ta-p/1300209
Have you changed the JDE you use in this project? Newer JDEs are not compatible with previous OS. I have encountered same problem before, some UI components are not available after I changed JDE to 4.7.