8

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.

enter image description here

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.

Asif Raza
  • 836
  • 12
  • 29
  • See this demo app may help u : https://developer.apple.com/library/content/samplecode/Speakerbox/Introduction/Intro.html – Dhaval Bhadania Aug 09 '17 at 05:38
  • I have already seen it. Here also they used same methodology for setting AppIcon in configuration. Like....... if let iconMaskImage = UIImage(named: "IconMask") { providerConfiguration.iconTemplateImageData = UIImagePNGRepresentation(iconMaskImage) } – Asif Raza Aug 09 '17 at 06:03
  • open var iconTemplateImageData: Data? // Image should be a square with side length of 40 points – Dhaval Bhadania Aug 09 '17 at 06:25
  • I know the size should be 40 points as I have explained above. I have also checked that Apple has used in above provided link same as I have used. – Asif Raza Aug 09 '17 at 08:51

2 Answers2

11

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.

Stuart M
  • 11,458
  • 6
  • 45
  • 59
  • I edited my existing logo such that only the borders are visible, the rest of it is transparent. Final result looks cool. Thnx @Stuart M, it works on my side. Your answer should be the accepted answer. – AndaluZ Jun 05 '18 at 13:06
1

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

enter image description here

Asad Farooq
  • 191
  • 1
  • 13