Skip to content

Commit f69cca3

Browse files
author
cpandya25
committed
cp-10932-banner-with-custom-font-implement-font-create-guide
Add iOS app banner custom font documentation.
1 parent 2e7b729 commit f69cca3

5 files changed

Lines changed: 94 additions & 0 deletions

File tree

docs/sdks/ios/methods.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,100 @@ CleverPush.getAppBanners(byGroup: groupId) { banners in
512512
<!--END_DOCUSAURUS_CODE_TABS-->
513513
514514
515+
### Custom Fonts for App Banners
516+
517+
You can apply custom fonts to app banner text and buttons to match your app branding.
518+
519+
**Supported Font Formats**
520+
521+
The following font formats are supported:
522+
523+
* `.ttf` - TrueType
524+
* `.otf` - OpenType
525+
526+
**Step 1: Add the font files to your iOS app**
527+
528+
1. Drag your font files (for example `OpenSans-Regular.ttf`) into your Xcode project.
529+
2. Make sure the files are added to your app target.
530+
3. Verify they appear in **Build Phases** -> **Copy Bundle Resources**.
531+
532+
Example (font files in project):
533+
534+
![iOS Fonts Folder Example](/img/sdks/ios/custom-fonts/fonts-folder-example.png)
535+
536+
Example (**Copy Bundle Resources**):
537+
538+
![iOS Copy Bundle Resources Example](/img/sdks/ios/custom-fonts/copy-bundle-resources.png)
539+
540+
**Step 2: Register fonts in `Info.plist`**
541+
542+
Add the `Fonts provided by application` (`UIAppFonts`) key and list all font files (with extension):
543+
544+
```xml
545+
<key>UIAppFonts</key>
546+
<array>
547+
<string>OpenSans-Regular.ttf</string>
548+
<string>OpenSans-Bold.ttf</string>
549+
<string>OpenSans-Italic.ttf</string>
550+
<string>OpenSans-Light.ttf</string>
551+
<string>OpenSans-LightItalic.ttf</string>
552+
<string>OpenSans-Semibold.ttf</string>
553+
<string>OpenSans-ExtraBold.ttf</string>
554+
</array>
555+
```
556+
557+
Example (`UIAppFonts` in `Info.plist`):
558+
559+
![iOS UIAppFonts Info.plist Example](/img/sdks/ios/custom-fonts/uiappfonts-info-plist.png)
560+
561+
**Step 3: Use the iOS font name in your App Banner**
562+
563+
When configuring the banner font in the CleverPush dashboard:
564+
565+
* Use the iOS internal font name (PostScript name), not necessarily the file name.
566+
* Example: file `OpenSans-Regular.ttf` can expose a font name like `OpenSans-Regular`.
567+
* Set the **Font Family** field to `OpenSans-Regular`.
568+
569+
Example (CleverPush dashboard font field):
570+
571+
![iOS Dashboard Font Family Example](/img/sdks/ios/custom-fonts/dashboard-font-family-example.png)
572+
573+
You can verify a font name in code:
574+
575+
<!--DOCUSAURUS_CODE_TABS-->
576+
577+
<!--Swift-->
578+
579+
```swift
580+
if let font = UIFont(name: "OpenSans-Regular", size: 16) {
581+
print("Loaded font: \(font.fontName)")
582+
}
583+
```
584+
585+
<!--Objective-C-->
586+
587+
```objective-c
588+
UIFont *font = [UIFont fontWithName:@"OpenSans-Regular" size:16];
589+
if (font) {
590+
NSLog(@"Loaded font: %@", font.fontName);
591+
}
592+
```
593+
594+
<!--END_DOCUSAURUS_CODE_TABS-->
595+
596+
Use this resolved font name in the App Banner font fields.
597+
598+
**Step 4: Build and test**
599+
600+
1. Rebuild and run your iOS app.
601+
2. Trigger the app banner.
602+
3. Confirm custom fonts are applied to the banner text and buttons.
603+
604+
**Fallback Behavior**
605+
606+
If the custom font is missing, named incorrectly, or cannot be loaded, the SDK falls back to the system font so the banner remains readable.
607+
608+
515609
### Disabling banners
516610
517611
You can also disable app banners temporarily, e.g. during a splash screen. Banners are enabled by default.
127 KB
Loading
592 KB
Loading
120 KB
Loading
81.7 KB
Loading

0 commit comments

Comments
 (0)