패키지, 저장소 및 앱 카테고리 검색

flutter_dynamic_icon 표지
패키지 상세v2.1.0

flutter_dynamic_icon

앱 아이콘과 앱 아이콘 배치 번호를 동적으로 변경하기 위한 플러터 플러그인

AndroidiOS
30일 다운로드
2.2천
좋아요
423
Pub 점수
150

패키지 설치

flutter pub add flutter_dynamic_icon

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Android 및 iOS에서 동적 앱 아이콘 변경 및 일괄 번호 업데이트를 가능하게 하는 플러터 플러그인입니다. 개발자가 런타임에 프로그래밍 방식으로 앱 아이콘을 전환할 수 있게 해주며, 커스텀 브랜딩, 계절 테마 또는 사용자 선호도에 유용합니다. 플러그인은 플랫폼별 아이콘 관리와 버전 관리 또는 프로모션 목적의 일괄 번호 지정을 지원합니다. 네이티브 코드 수정 없이 플러터 앱과 원활하게 통합되도록 설계되어 있으며, 시각적 유연성 또는 인터랙티브한 아이콘 경험을 필요로 하는 앱에 적합합니다.

사용 사례

  • 사용자 선호도에 따라 앱 아이콘 변경
  • 계절 또는 이벤트 기반 아이콘 업데이트
  • 앱 브랜딩 사용자 지정
  • 다른 아이콘 변형 테스트
  • 프로모션 캠페인 아이콘 전환

주요 기능

  • 런타임 중 동적 아이콘 전환
  • Android 및 iOS 지원
  • 배치 번호 관리
  • 간단한 API 통합
  • 원시 코드가 필요하지 않습니다

적합한 대상

  • 사용자 정의 가능한 UI를 가진 앱
  • 브랜딩 중심 애플리케이션
  • 이벤트 기반 또는 계절적 앱
  • 아이콘 테스트용 개발 도구
  • 마케팅 또는 프로모션 캠페인

고려 사항

  • 아이콘 변경 후 앱 재시작 필요
  • 일부 오래된 장치에서 지원이 제한됨
  • iOS는 추가 구성이 필요합니다
  • 아이콘 자산은 사전에 정의되어야 합니다
  • 자주 아이콘을 변경하는 데 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_dynamic_icon

A flutter plugin for dynamically changing app icon and app icon batch number in the mobile platform. Supports only iOS (with version > 10.3).

Usage

To use this plugin, add flutter_dynamic_icon as a dependency in your pubspec.yaml file.

Getting Started

Check out the example directory for a sample app using flutter_dynamic_icon.

iOS Integration
Index
  • 2x - 120px x 120px
  • 3x - 180px x 180px

To integrate your plugin into the iOS part of your app, follow these steps

  1. First let us put a few images for app icons, they are
    • teamfortress@2x.png, teamfortress@3x.png
    • photos@2x.png, photos@3x.png,
    • chills@2x.png, chills@3x.png,
  2. These icons shouldn't be kept in Assets.xcassets folder, but outside. When copying to Xcode, you can select 'create folder references' or 'create groups', if not you will get and error when uploading the build to the AppStore saying: (Thanks to @nohli for this observation) TMS-90032: Invalid Image Path - - No image found at the path referenced under key 'CFBundleAlternateIcons':...

Here is my directory structure:

directory_structure

  1. Next, we need to setup the Info.plist
    1. Add Icon files (iOS 5) to the Information Property List
    2. Add CFBundleAlternateIcons as a dictionary, it is used for alternative icons
    3. Set 3 dictionaries under CFBundleAlternateIcons, they are correspond to teamfortress, photos, and chills
    4. For each dictionary, two properties — UIPrerenderedIcon and CFBundleIconFiles need to be configured
    5. If the sub-property UINewsstandIcon is showing under Icon files (iOS 5) and you don't plan on using it (it is intended for use with Newstand features), erase it or the app will get rejected upon submission on the App Store

Note that if you need it work for iPads, You need to add these icon declarations in CFBundleIcons~ipad as well. See here for more details.

Here is my Info.plist after adding Alternate Icons

Screenshot

info.plist

Raw
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIcons</key>
	<dict>
		<key>CFBundleAlternateIcons</key>
		<dict>
			<key>chills</key>
			<dict>
				<key>CFBundleIconFiles</key>
				<array>
					<string>chills</string>
				</array>
				<key>UIPrerenderedIcon</key>
				<false/>
			</dict>
			<key>photos</key>
			<dict>
				<key>CFBundleIconFiles</key>
				<array>
					<string>photos</string>
				</array>
				<key>UIPrerenderedIcon</key>
				<false/>
			</dict>
			<key>teamfortress</key>
			<dict>
				<key>CFBundleIconFiles</key>
				<array>
					<string>teamfortress</string>
				</array>
				<key>UIPrerenderedIcon</key>
				<false/>
			</dict>
		</dict>
		<key>CFBundlePrimaryIcon</key>
		<dict>
			<key>CFBundleIconFiles</key>
			<array>
				<string>chills</string>
			</array>
			<key>UIPrerenderedIcon</key>
			<false/>
		</dict>
	</dict>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>flutter_dynamic_icon_example</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>
</dict>
</plist>

Now, you can call FlutterDynamicIcon.setAlternateIconName with the CFBundleAlternateIcons key as the argument to set that icon.

Dart/Flutter Integration

From your Dart code, you need to import the plugin and use it's static methods:

import 'package:flutter_dynamic_icon/flutter_dynamic_icon.dart';

try {
  if (await FlutterDynamicIcon.supportsAlternateIcons) {
    await FlutterDynamicIcon.setAlternateIconName("photos");
    print("App icon change successful");
    return;
  }
} on PlatformException {} catch (e) {}
print("Failed to change app icon");

...

// set batch number
try {
	await FlutterDynamicIcon.setApplicationIconBadgeNumber(9399);
} on PlatformException {} catch (e) {}

// gets currently set batch number
int batchNumber = FlutterDynamicIcon.getApplicationIconBadgeNumber();

Check out the example app for more details

Screenrecord

Showing App Icon change

Screenrecording of the example

Showing Batch number on app icon change in SpringBoard

Screenrecording of the example

Reference

This was made possible because this blog. I borrowed a lot of words from this blog. https://medium.com/ios-os-x-development/dynamically-change-the-app-icon-7d4bece820d2

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.