AVAudioRecorder is not respecting AVLinearPCMBitDepthKey setting - ios7

I'm using AVAudioRecorder in my app. Configuration looks like this:
....
AVAudioRecorder *internalRecorder = [[AVAudioRecorder alloc] initWithURL:url settings:[self recordSettings] error:&error];
....
- (NSDictionary *)recordSettings __attribute__((const)) {
return #{AVFormatIDKey: #(kAudioFormatAppleLossless),
AVSampleRateKey: #(44100.0),
AVLinearPCMBitDepthKey: #(16),
AVLinearPCMIsBigEndianKey: #NO,
AVLinearPCMIsFloatKey: #NO};
}
Audio recorded on iOS 7 has 16 bit, but on iOS 8 has 32 bit. Is it a bug in iOS 8? I'm using both Xcode 5 and Xcode 6 - problem is not related to Xcode version.
Thank you in advance.

Related

Troubles getting an actual macOS version

I'm using the following code:
NSOperatingSystemVersion macOsVersion()
{
return [[NSProcessInfo processInfo] operatingSystemVersion];
}
It's working fine when I build it on my machine - it returns 11.5.1 version.
But, we use Jenkins, which is working on a remote macOS machine, and a build from Jenkins shows 10.16.0 version on my machine.
I'm not an experienced macOS developer. Am I doing something wrong? Is there a better API?
You could try this way, which is not dependent on which SDK you are linking to:
NSDictionary* systemVersion = [NSDictionary dictionaryWithContentsOfFile:#"/System/Library/CoreServices/SystemVersion.plist"];
NSString *macOSVersion = [systemVersion objectForKey:#"ProductVersion"];
NSLog (#"productVersion =========== %#", macOSVersion);
Thanks to CTABUYO for the code example, and mikdusan, the solution is to read contents of the /System/Library/CoreServices/.SystemVersionPlatform.plist file. It's not affected by macOS version compatibility stuff (at least for now).
if (FileExists("/System/Library/CoreServices/.SystemVersionPlatform.plist"))
{
NSDictionary* systemVersion = [NSDictionary dictionaryWithContentsOfFile:#"/System/Library/CoreServices/.SystemVersionPlatform.plist"];
NSString *macOSVersion = [systemVersion objectForKey:#"ProductVersion"];
NSLog (#"productVersion =========== %#", macOSVersion);
}
else
{
NSDictionary* systemVersion = [NSDictionary dictionaryWithContentsOfFile:#"/System/Library/CoreServices/SystemVersion.plist"];
NSString *macOSVersion = [systemVersion objectForKey:#"ProductVersion"];
NSLog (#"productVersion =========== %#", macOSVersion);
}

Native cellular call fails on VoIP incoming call in iOS 13

I have implemented CallKit for audio and video call with VoIP PushKit in iOS and it is working fine in iOS 12 and prior versions, and also it is working fine normally in iOS 13 and 13.1.
But it is failing in 2 scenarios:
1) Our App is in foreground state. When cellular call is running and VoIP push is received, then Call kit incoming call screen is showing for 5 - 10 seconds, and then both Cellular and VOIP calls are failing with Alert "Call Failed".
2) Our App is in Background or Killed state. When cellular call is running and VoIP push is received, then both Cellular and VOIP calls are failing with Alert "Call Failed". No incoming call UI is showing this time.
I am showing my code here:
- (void)registerAppForVOIPPush {
PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
pushRegistry.delegate = self;
pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
}
Then Push delegates
#pragma mark PKPushRegistryDelegate ----
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {
NSString *newToken = [self hexadecimalStringFromData:credentials.token];
//Make a note of this token to a server to send VOIP for a particular device
NSLog(#"VOIP token ::: %#", newToken);
_voipToken = newToken;
}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type {
//available(iOS, introduced: 8.0, deprecated: 11.0)
[self pushRegistryDidReceivedPushWithPayload:payload forType:type withCompletionHandler:NULL];
}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
//available(iOS 11.0, *)
[self pushRegistryDidReceivedPushWithPayload:payload forType:type withCompletionHandler:completion];
}
- (void)pushRegistryDidReceivedPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
//Call kit configration
CXProviderConfiguration *providerConfig = [[CXProviderConfiguration alloc] initWithLocalizedName:#"my app Call"];
providerConfig.supportsVideo = NO;
providerConfig.maximumCallGroups = 1;
providerConfig.maximumCallsPerCallGroup = 1;
providerConfig.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInteger:CXHandleTypeGeneric], nil];
providerConfig.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:#"IconMask"]);
CXProvider *provider = [[CXProvider alloc] initWithConfiguration:providerConfig];
[provider setDelegate:self queue:nil];
//generate token
NSUUID *callbackUUIDToken = [NSUUID UUID];
//Display callkit
NSString *uniqueIdentifier = #"Max test";
CXCallUpdate *update = [[CXCallUpdate alloc] init];
update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:uniqueIdentifier];
update.supportsGrouping = FALSE;
update.supportsUngrouping = FALSE;
update.supportsHolding = FALSE;
update.localizedCallerName = uniqueIdentifier;
update.hasVideo = NO;
[provider reportNewIncomingCallWithUUID:callbackUUIDToken update:update completion:^(NSError * _Nullable error) {
NSLog(#"reportNewIncomingCallWithUUID error: %#",error);
}];
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion();
});
}
}
I have implemented CXProvider delegate method perfectly
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action{
[action fulfill];
}
- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action{
[action fulfill];
}
and also managed other delegate methods to manage call and everything, and it is working perfectly in all conditions.
I have checked these two scenarios with other apps like Google Duo, Whatsapp and FaceTime and it's showing CallKit properly without failing, but in my app it is failing. I have no clue where it is failing.
So, I have this 2 stated issues for iOS 13 and later versions. Any help will be appreciated.
Thanks.
This is probably an iOS 13 bug and, if you haven't already done it, you should report it to Apple.
I think that the reason why apps like Whatapp (and the one I develop) are working, is that we build the app against the iOS 12 SDK. We do this because of the limitations of VoIP push notifications introduced in iOS 13. So, you can try to work around the issue—at least until April 2020—building against the iOS 12 SDK. Hopefully, Apple we'll soon fix this issue.
#Max I have faced the same issue that you faced in iOS version 13.0 to 13.2.0.
As many developers have reported this issue to Apple. The latest iOS version that released last week(iOS 13.2.2) has this bug resolved. So, now instead of building from older SDK, you can start working with latest SDK and xCode 11.2.1.

How to check Current SDK version of Google AdMob iOS?

Google has Changed some Policy under which the ads displayed under SDK version 7.0 will not display ads any more, Actually i don't know which version SDK i m using.
Please help me to get out of this.
pragma mark GADRequest implementation
- (GADRequest *)request {
GADRequest *request = [GADRequest request];
NSLog(#"Received ad successfully %# " , [GADRequest sdkVersion] );
request.testDevices = #[
kGADSimulatorID
];
return request;
}
Implement the above code in your iOS Project
And Check Log
you will get Output something like this
afma-sdk-i-v7.27.0
SWIFT:
print(GADMobileAds.sharedInstance().sdkVersion)
NSLog(#"admob version %# " ,[[GADMobileAds sharedInstance] sdkVersion]);

Scanning BarCode from image Gallery ios 7

I want to scan a barcode or QR code image which is in my photo gallery in ios 7. In ios 7 we can use camera to scan a bar code image but I did not find any method to select a Bar code image from UIImagePickerController and scan it. Is there any methods available in AVFoundation Framework ?
Help me..
I have the same issue, most of the once perfectly running 32 bit barcode SDKs are broken with 7.1 due to the architecture requirement to support arm64. Zbar is affected, ZXing totally got out of the iOS platform what is left are commercial packages. I tried one of them called manatee it works but it is truncating the first character of the barcode from the output. At the moment your best bet are these commercial SDKs working with IOS 7.1 or go back to 7.0 or 6.1 and use Zbar.
AVfoundation solution put forward by #Stark works well with camera capture (I've tested it with some modifications to recognise PDF417, AztecCodes, and 6 or so 1D barcodes),however the codes in the sample app cannot process existing images from the media library. I searched intensively and the nearest bet is the CoreImage detection which does facial recognition on images, unfortunately there is no barcode detection option yet.
There are many APIs available for barcode scanning:-
Softek Barcode Reader SDK
ZBar bar code reader
shopsavvy
red laser
ZXing
If you want to use AVfoundation framework only, here is the link for the tutorial..
http://www.appcoda.com/qr-code-ios-programming-tutorial/
Here is the code which start Reading the barcode
- (BOOL)startReading {
NSError *error;
AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if (!input) {
NSLog(#"%#", [error localizedDescription]);
return NO;
}
_captureSession = [[AVCaptureSession alloc] init];
[_captureSession addInput:input];
AVCaptureMetadataOutput *captureMetadataOutput = [[AVCaptureMetadataOutput alloc] init];
[_captureSession addOutput:captureMetadataOutput];
dispatch_queue_t dispatchQueue;
dispatchQueue = dispatch_queue_create("myQueue", NULL);
[captureMetadataOutput setMetadataObjectsDelegate:self queue:dispatchQueue];
[captureMetadataOutput setMetadataObjectTypes:[NSArray arrayWithObject:AVMetadataObjectTypeQRCode]];
_videoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
[_videoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[_videoPreviewLayer setFrame:_viewPreview.layer.bounds];
[_viewPreview.layer addSublayer:_videoPreviewLayer];
[_captureSession startRunning];
return YES;
}
and to stop it.
-(void)stopReading{
[_captureSession stopRunning];
_captureSession = nil;
[_videoPreviewLayer removeFromSuperlayer];
}

Iphone SDK 4 sms composer

Have anyone tried to use the SDK4's SMS composer?
If anyone's got some reference or source code please put in here
Thanks
If you want to support 3.1 devices, you need to do a few things:
In your target's build settings:
set Base SDK to iPhone Device 4.0
set iPhone OS Deployment Target to iPhone OS 3.x (the lowest OS level you want to support)
In your target's general settings, under Linked Libraries, change the "Type" next to MessageUI.framework to Weak.
Don't import <MessageUI/MFMessageComposeViewController.h> or it will crash on launch on 3.1. Just import <MessageUI/MessageUI.h>
To make sure it doesn't crash on 3.1.x, you need to test for the availability of MFMessageComposeViewController:
Class smsClass = (NSClassFromString(#"MFMessageComposeViewController"));
if (smsClass != nil && [MFMessageComposeViewController canSendText]) {
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
controller.body = text;
controller.recipients = [NSArray arrayWithObjects: nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
[controller release];
}
If you've got the 4.0 SDK already, check MFMessageComposeViewController. The usage is similar to MFMailComposeViewController.