App icon is not showing in CallKit UI - ios

I have configured my Provider Configuration for CallKit iOS. In which I have also set 'iconTemplateImageData' for displaying app icon in CallKit UI. But app icon is not showing. It shows a white square box.
Provider Configuration Code:
CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] initWithLocalizedName:[NSString stringWithFormat:#"%#\n", _title]];
configuration.maximumCallGroups = 1;
configuration.maximumCallsPerCallGroup = 1;
UIImage *callkitIcon = [UIImage imageNamed:#"AppIcon"];
configuration.iconTemplateImageData = UIImagePNGRepresentation(callkitIcon);
_callKitProvider = [[CXProvider alloc] initWithConfiguration:configuration];
[_callKitProvider setDelegate:self queue:nil];
_callKitCallController = [[CXCallController alloc] initWithQueue:dispatch_get_main_queue()];
I have used AppIcon images in 'Images.xcassets' with sizes: -
1x: 40*40, 2x: 80*80, 3x: 120*120
Please help why my app icon is not showing.
Thanks in advance.

This is likely because you are using your AppIcon image, which is a fully opaque image, i.e. no part of that image is transparent or has alpha=0.
To get the desired effect, you have to use a different image which is partly (or mostly) transparent. The native in-call UI will only use the alpha channel of the image you provide, so it ignores colors. I suggest following the example in the Speakerbox sample app and providing a secondary PNG image in your image asset catalog with transparency.

You need to use below code in order to set app name and app icon for incoming VOIP calls
let localizedName = NSLocalizedString("App-Name", comment: "Name of application")
let providerConfiguration = CXProviderConfiguration(localizedName: localizedName)
providerConfiguration.iconTemplateImageData = UIImage.init(named: "appicon-Name")?.pngData()
Note: Your app icon must be transparent. result will be like in below image

Related

Disable image recognition for UIImageView on iOS 14 with VoiceOver

I have a UIImageView as the background for a view. User interaction is disabled. isAccessibilityElement is set to NO. This is verified by using debug view hierarchy when the app is running on device.
And yet when I tap on the view that has that as the background is describes all the controls on it and then describes the image using automatic image recognition. Everything I've found online says this is a new iOS 14 feature and that it's great, but says nothing about how I can turn it off.
I even tried setting my own description string to at least try to override the image recognition to no avail. So - IS there a way to turn it off for a specific UIImageView(or even for the app overall) and if so how?
*** update ****
So I've confirmed this is specific to iOS 14. I have the following code in viewDidLoad:
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"blueSky.jpg"]];
imageView.isAccessibilityElement = YES;
imageView.accessibilityLabel = #"I am not a description";
CGPoint origin = imageView.frame.origin;
origin.y = 50;
origin.x = 50;
CGRect imageFrame = imageView.frame;
imageFrame.origin = origin;
imageView.frame = imageFrame;
self.view.isAccessibilityElement = NO;
[self.view addSubview:imageView];
Where blueSky is, well, an image of blue sky. It's not using the asset catalogue. When I tap on the image with VoiceOver enabled in iOS 13 it reads "I am not a description". When I tap on it on an iOS 14.1 device it reads "I am not a description", then pauses for half a second, says "image", then proceeds to describe it "blue sky, cloudy". It's that last part that I cannot for the life of me figure out how to eliminate!
So I found the answer:
imageView.accessibilityTraits = UIAccessibilityTraitNone;
This tells the system to not consider it an image and so it doesn't try to recognize it.

Any way to get light image when iPhone is on dark mode?

> UITraitCollection *lightTrait = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight];
image = [UIImage imageNamed:name inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:lightTrait];
I want to get the image on light model , regardless of what the current theme of the iOS device is.
But the above code does not seem to work.
Odd, I don't see what's wrong with your code.
You can also try the following:
let lightImage = image.imageAsset?.image(with: lightTrait)

Specify asset image for UIImageView for all devices

Is there a way I can say for a particular UIImageView:
UIImageView *imageView = <#instantiate#>
imageView.image = #"someImageFromImageAsset";
and based on the device it's rendering on, it sets the right image. Obviously I need to set the image for a particular device but I am unsure how you do it.
iOS will automatically choose the correct sized image if you just use the name of the image. Use #2x in the image file name for retina display.
Objective-C
imageView.image = [UIImage imageNamed: #"someImageName"];
Swift
imageView.image = UIImage(named: "someImageName");

ios sharekit 2.0 not showing image preview when sharing image

I'm using Sharekit2.0 to share images to facebook and twitter.
Here is the code used for sharing the image in facebook.
SHKItem *sharerItem = [SHKItem image:image title:#""];
SHKTwitter *sharer = [[SHKTwitter alloc] init];
[sharer setItem:sharerItem];
[sharer share];
But this not showing any preview of the image when sharing (like twitter is showing). just a text view to enter title for image.
My question would be: is it possible to show to image preview when sharing to facebook ?
Thanks
Try:
SHKItem * sharerItem = [SHKItem image:image title:#"P"];
[SHKTwitter shareItem:sharerItem];

How to remove square ratio cropping for images on IOS

I am using the IOS standard image cropping functionality (move and scale) to crop my image before submitting it to the server.
However, I realize that the cropping provided has a square ratio (see screenshot below)
Snippet of the code is as follows:
//set up image picker
self.imgPicker = [[[UIImagePickerController alloc] init]autorelease];
self.imgPicker.allowsEditing = YES;
self.imgPicker.delegate = self;
//Trigger get photo from library function
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.imgPicker animated:YES];
How can allow 'move and scale' editing and at the same time allow the user to do cropping WITHOUT the square ratio restriction?
I think you need change self.imgPicker.allowsEditing = YES; to self.imgPicker.allowsEditing = NO;
This library can help you.
https://github.com/gekitz/GKImagePicker
It supports custom cropping and it's easy to integrate with the native picker if needed.
I think , this will serve your purpose . You can change the constraints as you want
https://github.com/kishikawakatsumi/PEPhotoCropEditor?source=cc

Resources