์๋
,
ํธ์ ์๋ฆผ์ด ์ ๋ฌ๋ ๋ Android ์ํ ํ์์ค์ ํ์๋๋ ์์ด์ฝ์ ๋ณ๊ฒฝํ๋ ค๊ณ ํ์ต๋๋ค. ๋ค์์ ํ์ฌ ์งํ ์ค์ธ ์ํฉ์ ์์
๋๋ค.
๋ณด์๋ค์ํผ ๋ด ์ฑ์ ์์ด์ฝ์ ํฌ๋ช
ํ ์ด๋ฏธ์ง๊ฐ ์๋๋๋ค. ํฌ๋ช
์ด๋ฏธ์ง๋ก ๋ณ๊ฒฝํ๋ฉด ํธ์ ์์ด์ฝ์ด ๊ด์ฐฎ์ ๋ณด์ด์ง๋ง ์ฑ ์์ด์ฝ์ ์ด์ ํฌ๋ช
์ด๋ฏธ์ง์ด๊ณ ๋ด๊ฐ ์ํ๋ ๊ฒ์ด ์๋๋๋ค. ๋ค์ํ ํ์ผ ์ด๋ฆ์ ์๋ํ์ง๋ง ์๋ฌด ๊ฒ๋ ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค. 73ํ์ src/android/FirebasePluginMessagingService.java ์ฝ๋๋ฅผ ์ดํด๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
.setSmallIcon(getApplicationInfo().icon)
์ฑ ์์ด์ฝ๊ณผ ๋ค๋ฅธ ์์ด์ฝ์ ์ค์ ํ ์ ์๋ค๋ ๋ง์ด ๋ง๋์?
์ํ ํ์์ค ์์ด์ฝ์ ๋ํด ๋ค๋ฅธ ํ์ผ์ ์ค์ ํ ์ ์์ต๋๊น?
๋๋ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ๋ํ ๋ค๋ฅธ ์ ์ ์ฌํญ์ด ์์ต๋๊น?
๋๋ ์ด๊ฒ์ ํ ์คํธํ์ง ์์์ง๋ง fcm_push_icon.png๋ฅผ ํ์ํ ๋ชจ๋ ํฌ๊ธฐ๋ก ๋ง๋ค์ด ์ฌ์ฉ์ ์ ์ ์์ด์ฝ์ ์ค์ ํ ์ ์์ด์ผ ํฉ๋๋ค. fcm_push_icon.png๊ฐ ์กด์ฌํ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก ์ฑ ์์ด์ฝ์ด ์ฌ์ฉ๋ฉ๋๋ค. ์์ด์ฝ์ android/res ํด๋ ํธ๋ฆฌ์ ์์ด์ผ ํฉ๋๋ค.
์ด๊ฒ์ ์ฌ์ฉํ์ฌ ๋ค์ํ ํฌ๊ธฐ๋ฅผ ๋ชจ๋ ์์ฑํ ์ ์์ต๋๋ค. http://romannurik.github.io/AndroidAssetStudio/icons-notification.html
์๋
ํ์ธ์, ์ฐ๋ฆฌ๋ ๊ฐ์ ๋ฌธ์ ์ ์ง๋ฉดํ๊ณ ์์ต๋๋ค. android/res ํด๋ ํธ๋ฆฌ์ fcm_push_icon.png
์์ด์ฝ์ ๋ฐฐ์นํ๋ ค๊ณ ํ์ง๋ง ์๋ฆผ ์์ด์ฝ์ ์ฌ์ ํ โโํฐ์์
๋๋ค.
@MikeBateman ํด๊ฒฐ์ฑ ์ ์ฐพ์์ต๋๊น?
์๋ ํ์ธ์, ์ฑ์ ๋์ SDK๋ฅผ ๋ณ๊ฒฝํ ์ ์๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ์ด๊ฒ์ ํ์ธํ์ญ์์ค. ๋ฌผ๋ก ์ ์ ํ ์๋ฃจ์ ์ ์๋๋๋ค.
๋๋ ์ฐ๊ตฌํ๊ณ ์ด ์๋ฃจ์ ์ ์ป์์ต๋๋ค.
์ด ๊ฒฝ๋ก src/android/FirebasePluginMessagingService.java๋ก ์ด๋ํ์ฌ .setSmallIcon(getApplicationInfo().icon)
ํ์ ์ฐพ์ผ์ญ์์ค( @MikeBateman ์ธ๊ธ๊ณผ ๊ฐ์ด). ์ด์ ์ฑ์ด Android lollipop+์์ ์คํ ์ค์ธ์ง ํ์ธํ๋ ์กฐ๊ฑด์ ์ถ๊ฐํ์ญ์์ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ๋จธํฐ๋ฆฌ์ผ ๋์์ธ ์์ด์ฝ ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ๊ธฐ๋ณธ ์ฑ ์์ด์ฝ์ธ ์ฝ๋๋ฅผ ์ฌ์ฉํฉ๋๋ค.
...
.setSmallIcon(getNotificationIcon())
...
//At the end of FirebasePluginMessagingService.java
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
System.out.println("SCLMTEST >lollipop?:"+useWhiteIcon);
return useWhiteIcon ? R.drawable.myMaterialIcon: getApplicationInfo().icon;
}
๋ด ์๊ฐ์ ๊ฐ์ฅ ์ข์ ๊ฒ์ myappresources์ ๋จธํฐ๋ฆฌ์ผ ๋์์ธ ์์ด์ฝ์ ๋ฃ๊ณ ํ๋ฌ๊ทธ์ธ์ด ์ด ์์ ์ ์์ฒด์ ์ผ๋ก ์ํํ๋ ๊ฒ์ ๋๋ค. ์ด์ ์ด๋ป๊ฒ ํด์ผํ ์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋๊ตฐ๊ฐ ํ ์ ์๋ค๋ฉด ํ๋ฅญํ ๊ฒ์ ๋๋ค. ๋์์ด ๋๊ธธ ๋ฐ๋๋๋ค! @delphaber
33c52c7e8a1835d5f595e58eaef43e4f49b4b23a์ ๊ณ ์
ํ๋ฌ๊ทธ์ธ์ ์ด์ ๋๋ก์ด๋ธ์์ notification_icon์ด ์๋ ๊ฒฝ์ฐ ์ด๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ ์ฑ ์์ด์ฝ์ ์ฌ์ฉํฉ๋๋ค
์ผ,
๋๋ ๊ทธ๊ฒ์ ์ดํดํ์ง ๋ชปํ๋ค. ๊ฐ ๋๋ก์ด๋ธ ํด๋(๊ฐ ํฌ๊ธฐ์ ๋ํด)์ notification_icon.png
๋ฅผ ๋ฃ์ผ๋ ค๊ณ ํ์ง๋ง ํ๋ฌ๊ทธ์ธ์ ์ฌ์ ํ โโ๊ธฐ๋ณธ ํด๋(์ฑ ์์ด์ฝ)๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๋ด๊ฐ ๋ญ๊ฐ๋ฅผ ๋์ณค๋์?
๊ฐ์ฌ ํด์!
@blckshrk cc/ @robertarnesson
Android src ํ์ผ์ ์
๋ฐ์ดํธํ๊ณ ๋ชจ๋ notification_icon.png
ํ์ผ์ ์ถ๊ฐํ ํ์๋ ์ฌ์ ํ ํฐ์ ์ฌ๊ฐํ์ด ํ์๋๋ ๋์ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋๋ ์ฌ๊ธฐ์์ ์กฐ์ธ์ ๋ฐ๋๋ค: http://stackoverflow.com/questions/37325051/notification-icon-with-the-new-firebase-cloud-messaging-system
๋จผ์ ๋ด ์ปดํจํฐ์์ ์ต์ Firebase SDK๋ฅผ ์ต์ ์ํ๋ก ๋ง๋ค๊ธฐ ์ํด Google Repository๋ฅผ ์
๋ฐ์ดํธํด์ผ ํ์ต๋๋ค. ์ด๊ฒ์ com.google.firebase:firebase-core
์ ๋ํ ๋ฒ์ 9.8.0์ด๋ฉฐ ์ด ๊ธ์ ์ฐ๋ ์๊ฐ์ ์๋ํ๊ฒ ๋ฉ๋๋ค. (๋๋ ์ด์ ์ 9.4.0์ ์์๋ค)
๊ทธ๋ฐ ๋ค์ ์ด๊ฒ์ AndroidManifest.xml
์ ์ถ๊ฐํ์ต๋๋ค.
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
default_notification_color
๋ฅผ ๋ณ๊ฒฝํ๋ ์ต์
์ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ์ฐ๋ฆฌ ์์ด์ฝ์ ๋ฐฐ๊ฒฝ์ด ํฌ๋ช
ํ ํฐ์ ์์ด์ฝ์ด๋ฏ๋ก ์ ๊ธ ํ๋ฉด์์ ๋ฉ์ง ์์์ ๋ค์ ์ถ๊ฐํ์ต๋๋ค.
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/orange" />
๋ํ ๋ค์๊ณผ ํจ๊ป res/values/colors.xml
ํ์ผ์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ๋ฌผ๋ก ๋ฐฐ๊ฒฝ์ ์ค์ ํ๋ ๊ฒฝ์ฐ ์ํ๋ ์์์ ์ ํํ ์ ์์ต๋๋ค.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="orange">#FF8614</color>
</resources>
์ด๊ฒ์ ๋ชจ๋ Firebase 9.8.0๋ถํฐ ์๋ํฉ๋๋ค.
@blckshrk ํ๋ก์ ํธ์ ์์ด์ฝ์ ์ด๋ป๊ฒ ์ถ๊ฐํฉ๋๊น? ํ๋ก์ ํธ์ config.xml์ ์ฌ์ฉํ์ฌ ๋ฆฌ์์ค์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ํด๋์ ๋ฃ์ผ๋ฉด ๋ด๊ฐ ์๋ ํ ์ฝ๋์ ํ์๋์ง ์์ต๋๋ค.
ํ์ฌ Ionic 2๋ฅผ ์ฌ์ฉํ์ฌ ์ฑ์ ๋ง๋ค๊ณ ๋ค์์ ์ํํ๊ณ ์์ต๋๋ค.
ionic์ res ํด๋์ ์์ด์ฝ ํ์ผ์ ์ถ๊ฐํ์์ผ๋ฏ๋ก ionic resources
๋ช
๋ น์ ์คํํ๋ฉด ๋ค์ํ ํ๋ฉด ํฌ๊ธฐ์ ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.
config.xml
ํ์ผ์ ์ด๋ฏธ์ง ๊ฒฝ๋ก๋ ์ถ๊ฐํฉ๋๋ค.
์ ํํ ์ด๋ป๊ฒ ํด์ผํ๋์ง ๋ต๋ณ์ข ๋ถํ๋๋ฆฝ๋๋ค..
๋๋ ๋ค์ดํฐ๋ธ ์๋๋ก์ด๋ ์ฝ๋์ ํด๋ ๊ตฌ์กฐ์ ๋ํ ์ง์์ด ์์ผ๋ฏ๋ก ๊ทธ์ ๋ฐ๋ผ ๋ต์ฅ์ ๋ณด๋ด์ฃผ์ธ์.
-๊ฐ์ฌ ํด์
์ค์ ๋ก @prantikv ์ฒ๋ผ ๋๋ ์ฝ๊ฐ ๊ธธ์ ์์์ต๋๋ค. Ionic 1์ ์ฌ์ฉํฉ๋๋ค(๊ทธ๋ฌ๋ ๋์ผํ ์ํฌํ๋ก ์ฌ์ฉ). ๋ด ์์ด์ฝ์ res/drawable/
๋ฃ๊ณ cordova-custom-config ๋ฅผ ์ฌ์ฉํ์ฌ AndroidManifest.xml
( manifest
๋
ธ๋์์ ์ง์ )์ <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
๋ฅผ ์ถ๊ฐํ๋ ค๊ณ ํ์ง๋ง ์๋ฌด๊ฒ๋ ์์๋๋ก ์๋ํ์ง ์์ต๋๋ค.
@gylippus com.google.firebase:firebase-core
๋ถ๋ถ์ โโ์ดํดํ์ง ๋ชปํฉ๋๋ค. ๋ฒ์ ์ ์ด๋ป๊ฒ ํ์ธํ๋์?
๊ณ ๋ง์ ์๋ค์!
@robertarnesson @gylippus ์์ ์์๊ฐ ์์ต๋๊น?
๋๋ cordova-custom-config ์ ํจ๊ป ์๋ํ๋๋ก ๊ด๋ฆฌํ์ต๋๋ค.
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>
๊ทธ๋ฆฌ๊ณ platforms/android/res/drawable/notification_icon.png
๋์ ์ฃผ์ ์ ์ ๋ง๋ก ๊ณ ๋ง์ต๋๋ค !
notification_icon.png
๊ฐ ๋ฃจํธ(๋๋ resources
) ํด๋์ ์๋ ๊ฒฝ์ฐ ์ด ์์
์ ์๋์ผ๋ก ์ํํ๋ ํํฌ(ํ์ผ ์ด๋ ๋ฐ ๋งค๋ํ์คํธ ํธ์ง)๊ฐ ์์ผ๋ฉด ์ข์ ์ ์์ต๋๋ค. ๊ตฌ์ฑ ํ์ผ). ๊ทธ๊ฒ์ ๋ํด ์ด๋ป๊ฒ ์๊ฐํ์ต๋๊น?
@blckshrk
์ธ๊ธ ํ๋๋ก ๋ค์ ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ ค๊ณ ์๋ํ์ต๋๋ค.
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>
๊ทธ๋ฌ๋ ๋น๋ ํ๋ก์ธ์ค ์ค์ ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
:processDebugResources
E:\Development\IONIC 2\allcouriertracking\allcouriertracking5\platforms\android\res\xml\config.xml:57 : AAPT: Error parsing XML: unbound prefix
FAILED
FAILURE: Build failed with an exception.
:processDebugResources
E:\Development\IONIC 2\allcouriertracking\allcouriertracking5\platforms\android\res\xml\config.xml:57 : AAPT: Error parsing XML: unbound prefix
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'I:\DEVELOPMENT PROGRAMS\android-sdk-windows\build-tools\24.0.3\aapt.exe'' finished with non-zero exit value 1
๊ทธ๋ฐ ๋ค์ AndroidManifest.xml์ ๋ค์์ ์๋์ผ๋ก ์ถ๊ฐํ์ต๋๋ค.
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
Android 4.4์์๋ ์๋ํ์ง๋ง Android 5.1์์๋ ์๋ํ์ง ์์ต๋๋ค.
์ด๋ค ๋ฒ์ ์ ์ํด ๋น๋ํ์
จ๋์?
๋ํ notification_icon.png
ํ์ผ์ ๋ชจ๋ drawable
ํด๋์ ์ถ๊ฐํ์
จ์ต๋๊น ์๋๋ฉด ํ๋๋ง ์ถ๊ฐํ์
จ์ต๋๊น?
@prantikv https://github.com/dpa99c/cordova-custom-config ๋ฅผ ์ค์นํ์ จ์ต๋๊น?
์ค์ ๋ก ์ ๋ ์ด ํํฌ https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.js ๋ฅผ ์ฌ์ฉํ์ฌ notification_icon.png
ํ์ผ์ ๊ฐ ๋๋ก์ด๋ธ ํด๋๋ก ์๋ ์ด๋ํฉ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก <platform name="android">
๋
ธ๋ ์์ ์ด๊ฒ์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
<hook src="hooks/after_prepare/android_custom_resources.js" type="after_prepare"/>
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>
๋๋ ๋ํ https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.js ํํฌ์ @gylippus ๊ฐ ์ ์ํ ์๋ฃจ์ ์ ์ฌ์ฉํ์ฌ ์์์ ์ฒ๋ฆฌํ ์ ์์์ต๋๋ค(๊ฐ์ฌํฉ๋๋ค!)
@blckshrk ์ ํ๋ฌ๊ทธ์ธ์ ์ค์นํ์ต๋๋ค.. ์ฌ์ฉ ์ค์ธ ์ด๋ฏธ์ง ํฌ๊ธฐ๋ฅผ ์๋ ค์ฃผ์ค ์ ์๋์.. ์ด๋ฏธ์ง ์น์์ ํฌ๊ธฐ(KB).
๊ทธ๋ฆฌ๊ณ ํ
์คํธํ ํ๋ซํผ์
๋๋ค.
์ด์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น? 20์ผ์งธ์ธ๋ฐ ์์ง๋ ํด๊ฒฐ์ด ์๋๋์? ๊ทธ๋๋ ๋ฌธ์ ๋ผ๋ฉด ๋ซ์ ์ ์๋ค?!
๋๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์๊ณ ์๋ฒ ์ธก์์ ํด๊ฒฐํ ์์์์ต๋๋ค. ๋๋ notification_icon.png๋ผ๋ ์ด๋ฆ์ platform-android ํด๋ ์์ drawable ํด๋์ ์์ด์ฝ์ ์๋์ผ๋ก ๋ฐฐ์นํ์ต๋๋ค.
Firebase ์ฝ์์ ํตํด ๊ณ์ ์๋ชป๋ ์์ด์ฝ์ด ํ์๋์ง๋ง ์์ฒด ์๋ฒ์์ ์์ฒญ ๋ณธ๋ฌธ์ผ๋ก ๋ค์์ ๋ณด๋
๋๋ค.
$fields = array(
"registration_ids" => "array of registration ids",
"notification" => array(
"body"=>"message to send as a body",
"icon"=>"notification_icon",
"color"=>"your color in hex"
),
"priority"=>10
);
์ด ๋์์ ๋ฐ๋๋๋ค
์ค์ ๋ก ์ผ๋ถ ๋ก๊น ๋ฐ ์ฝ๊ธฐ ํ์ FirebasePluginMessagingService.java / sendNotification ์ ์ ์ฒด notificationBuilder ์ฝ๋๋ ์๋ฆผ ํ์ด๋ก๋๊ฐ ์์ ๋ ์คํ๋์ง ์๊ธฐ ๋๋ฌธ์ ๋ฌด์๋ฏธํ ๊ฒ ๊ฐ์ต๋๋ค. ์์ด์ฝ ๋ฌธ์ ์ธ์๋ ๋๋ notificationBuilder ์ฝ๋๊ฐ .setSound(defaultSoundUri)๋ฅผ ์ํํ๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ์์ฌํ๊ธฐ ์์ํ์ง๋ง ์๋ฆผ์ด ํธ๋ ์ด์ ๋์ฐฉํ๋ฉด ์ฌ์๋์ง ์์ต๋๋ค.
์ด๊ฒ์ด ์๋ฆผ์ด ํ๋ฌ๊ทธ์ธ ์ฝ๋์ ์ํด ๋น๋๋๋ ๊ฒ์ด ์๋๋ผ ์๋ฆผ ํ์ด๋ก๋์์ ์ง์๋ฅผ ๋ฐ๋ FCM ์์ฒด์ ์ํด ๋น๋๋๊ธฐ ๋๋ฌธ์ ์์ sergiojup์ ์๋ฃจ์ ์ด ์๋ํ๋ ์ด์ ์ ๋๋ค.
์.. Android์์ onMessageReceived๋ ๋ค์๊ณผ ๊ฐ์ ๊ฒฝ์ฐ์๋ง ํธ์ถ๋ฉ๋๋ค.
*) ์๋ฆผ ํ์ด๋ก๋๋ง ์๊ณ ์ฑ์ด ํฌ๊ทธ๋ผ์ด๋์ ์์ต๋๋ค.
*) ์๋ฆผ ํ์ด๋ก๋์ ๋ฐ์ดํฐ ํ์ด๋ก๋๊ฐ ์๊ณ ์ฑ์ด ํฌ๊ทธ๋ผ์ด๋์ ์์ต๋๋ค.
*) ๋ฐ์ดํฐ ํ์ด๋ก๋๋ง ์๊ณ ์ฑ์ด ํฌ๊ทธ๋ผ์ด๋ ๋๋ ๋ฐฑ๊ทธ๋ผ์ด๋์ ์์ต๋๋ค.
๋ฐ๋ผ์ ์ด๋ฌํ ๊ฒฝ์ฐ onMessageReceived๋ ํธ์ถ๋์ง ์์ต๋๋ค.
*) ์๋ฆผ ํ์ด๋ก๋๋ง ์๊ณ ์ฑ์ด ๋ฐฑ๊ทธ๋ผ์ด๋์ ์์ต๋๋ค.
*) ์๋ฆผ ํ์ด๋ก๋ ๋ฐ ๋ฐ์ดํฐ ํ์ด๋ก๋๊ฐ ์๊ณ ์ฑ์ด ๋ฐฑ๊ทธ๋ผ์ด๋์ ์์
์ฝ๋๋ฅผ ๋ณด๋ฉด ํ๋ฌ๊ทธ์ธ์ด ์๋ฆผ์ ๋น๋ํ๋๋ก ํ๋ ์ ์ผํ ๋ฐฉ๋ฒ์ ์ฑ์ด ๋ฐฑ๊ทธ๋ผ์ด๋์ ์๋ ๋์ ์ ๋ชฉ๊ณผ ํ ์คํธ ์์ฑ์ด ๋ชจ๋ ์๋ ๋ฐ์ดํฐ ํ์ด๋ก๋๋ง ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค.
@blckshrk ๊ฐ์ฌํฉ๋๋ค!! ๋๋ ๋ง์นจ๋ด ๊ทธ๊ฒ์ ์๋ ์์ผฐ์ต๋๋ค!
Ionic v2 ๋ฐ [email protected] ์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ด์จ: 2.2.2
์ฝ๋ฅด๋๋ฐ: 6.5.0
npm: 4.6.1
์ฌ์ฉ์ ์ง์ ๊ตฌ์ฑ ํ๋ฌ๊ทธ์ธ์ ์ค์นํฉ๋๋ค.
$ ionic plugin add cordova-custom-config --fetch --save
https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.js ๋ฐ https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.js ๋ฅผ ๋ค์ด๋ก๋ํ์ญ์์ค. ํ๋ก์ ํธ ๋ฃจํธ์ "package-hooks"(๋๋ ์ํ๋ ๋ชจ๋ ๊ฒ)๋ผ๋ ์ ๋๋ ํ ๋ฆฌ.
package-hooks/android_custom_resources.js
package-hooks/android_custom_values.js
ํ๋ก์ ํธ ๋ฃจํธ(ํ๋ซํผ ๋ด๋ถ ์๋)์ ๋ค์ ๋๋ ํฐ๋ฆฌ์ ํ์ผ์ ๋ง๋ญ๋๋ค.
resources/android/custom/notification_icon.png
resources/android/values/styles.xml
notification_icon.png
๋ Android >= API 21 ์๋ฆผ ์์ด์ฝ์
๋๋ค. ๋ด ํฌ๊ธฐ๋ 144x144px์ด๋ฉฐ ๋ฉ์ง๊ฒ ๋ณด์
๋๋ค.
styles.xml
์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF8614</color>
</resources>
<widget ... xmlns:android="http://schemas.android.com/apk/res/android">
<platform name="android">
<hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
<hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
</config-file>
</platform>
<widget>
๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ ๋ค์ผ!
config.xml์ ๋ค์์ ์ถ๊ฐํ ์์น๋ฅผ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๊ทธ๊ฒ์ ๋ํ ํ? ๋ํ XML์ ์ต์ํ์ง ์์ต๋๋ค. ๋ค์์คํ์ด์ค์ ์ ํํ ๋ฌด์์ ์ถ๊ฐํด์ผ ํฉ๋๊น? @shamank
<widget ... xmlns:android="http://schemas.android.com/apk/res/android">
<platform name="android">
<hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
<hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
<hook src="package-hooks/android_fixes.js" type="after_prepare"/>
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
</config-file>
</platform>
<widget>
@Rockforced ์ฃ์กํฉ๋๋ค, ์ ๊ฐ ์์ฆ ์ฃผ๋ณ์ ์์์ต๋๋ค. ์๋ณธ ํ์ผ์ ์ดํด๋ณด์ญ์์ค(๋ฌผ๋ก ์ผ๋ถ ๊ต์ฒด๋ ํญ๋ชฉ ํฌํจ). ๋์์ด ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.example" version="1.0.20" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>Test</name>
<description>Blabla.</description>
<author email="[email protected]" href="https://example.com/">Example</author>
<content src="index.html"/>
<access origin="*"/>
<allow-navigation href="http://ionic.local/*"/>
<allow-navigation href="http://192.168.0.1:8100"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<platform name="android">
<allow-intent href="market:*"/>
<hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
<hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
<hook src="package-hooks/android_fixes.js" type="after_prepare"/>
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
</config-file>
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png"/>
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png"/>
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png"/>
<icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png"/>
<icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png"/>
<icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png"/>
<splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/>
<splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/>
<splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/>
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/>
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/>
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/>
</platform>
<platform name="ios">
<allow-intent href="itms:*"/>
<allow-intent href="itms-apps:*"/>
<icon height="57" src="resources/ios/icon/icon.png" width="57"/>
<icon height="114" src="resources/ios/icon/[email protected]" width="114"/>
<icon height="40" src="resources/ios/icon/icon-40.png" width="40"/>
<icon height="80" src="resources/ios/icon/[email protected]" width="80"/>
<icon height="120" src="resources/ios/icon/[email protected]" width="120"/>
<icon height="50" src="resources/ios/icon/icon-50.png" width="50"/>
<icon height="100" src="resources/ios/icon/[email protected]" width="100"/>
<icon height="60" src="resources/ios/icon/icon-60.png" width="60"/>
<icon height="120" src="resources/ios/icon/[email protected]" width="120"/>
<icon height="180" src="resources/ios/icon/[email protected]" width="180"/>
<icon height="72" src="resources/ios/icon/icon-72.png" width="72"/>
<icon height="144" src="resources/ios/icon/[email protected]" width="144"/>
<icon height="76" src="resources/ios/icon/icon-76.png" width="76"/>
<icon height="152" src="resources/ios/icon/[email protected]" width="152"/>
<icon height="167" src="resources/ios/icon/[email protected]" width="167"/>
<icon height="29" src="resources/ios/icon/icon-small.png" width="29"/>
<icon height="58" src="resources/ios/icon/[email protected]" width="58"/>
<icon height="87" src="resources/ios/icon/[email protected]" width="87"/>
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640"/>
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750"/>
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242"/>
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536"/>
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768"/>
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640"/>
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320"/>
</platform>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="android-targetSdkVersion" value="23"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashMaintainAspectRatio" value="true"/>
<preference name="SplashReloadOnOrientationChange" value="true"/>
<preference name="SplashScreenDelay" value="3000"/>
<preference name="FadeSplashScreen" value="false"/>
<preference name="FadeSplashScreenDuration" value="0"/>
<preference name="orientation" value="portrait"/>
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
<preference name="SplashScreen" value="screen"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="KeyboardDisplayRequiresUserAction" value="false"/>
<preference name="loadUrlTimeoutValue" value="700000"/>
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar"/>
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser"/>
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
</feature>
<plugin name="cordova-plugin-app-event" spec="~1.2.0"/>
<plugin name="cordova-plugin-device" spec="~1.1.3"/>
<plugin name="cordova-plugin-console" spec="~1.0.4"/>
<plugin name="cordova-plugin-whitelist" spec="~1.3.2"/>
<plugin name="cordova-plugin-splashscreen" spec="~4.0.2"/>
<plugin name="cordova-plugin-statusbar" spec="~2.2.2"/>
<plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
<plugin name="cordova-plugin-geolocation" spec="~2.4.1"/>
<plugin name="cordova-plugin-compat" spec="~1.1.0"/>
<plugin name="cordova-plugin-inappbrowser" spec="~1.6.1"/>
<plugin name="cordova-plugin-nativestorage" spec="~2.2.2"/>
<plugin name="cordova-plugin-firebase" spec="~0.1.20"/>
<plugin name="cordova.plugins.diagnostic" spec="~3.0.4"/>
<plugin name="cordova-plugin-googlemaps" spec="~1.4.0">
<variable name="API_KEY_FOR_ANDROID" value="blabla"/>
<variable name="API_KEY_FOR_IOS" value="blabla"/>
</plugin>
<plugin name="ionic-plugin-deeplinks" spec="~1.0.14">
<variable name="URL_SCHEME" value="blabla"/>
<variable name="DEEPLINK_SCHEME" value="https"/>
<variable name="DEEPLINK_HOST" value="www.blabla.com"/>
<variable name="ANDROID_PATH_PREFIX" value="/"/>
</plugin>
<plugin name="cordova-custom-config" spec="~3.2.0"/>
<icon src="resources/ios/icon/[email protected]"/>
<engine name="android" spec="~6.2.2"/>
</widget>
@shamank ์ด๊ฒ์ ๋ํด ๋๋จํ ๊ฐ์ฌํฉ๋๋ค. ํ๋ฃจ ์ข ์ผ ๋ฒ์ 0.1.24์ ์ธ์์ ์ด์ด ์์๊ณ ์๋ฃจ์ ์ด ์๋ํ์ต๋๋ค. ์ด๊ฒ์ด ์ฌ์ฉ์ ์ ์ ์์ด์ฝ์ด ์๋ํ๋ ์ด์ ๋ฅผ ์ ํํ ์๋ ค์ฃผ์ค ์ ์์ต๋๊น? ๋๋ ๋๋ฅผ ์์ฃผ ์์ธํ ์ฝ์ด์ฃผ๊ธฐ์ ์ง์นจ์ ๋ฐ๋๊ณ ํ์์ผ๋ก ํ์๋ ์์ด์ฝ๋ง ํ์ํ์ต๋๋ค. ๊ทํ์ ์๋ฃจ์ ์ ์ฆ์ ์๋ํ์ต๋๋ค... ์ด์ ๋ฅผ ์๊ณ ์ถ์ต๋๋ค!
@jskidd3 ๋์์ด ๋์๋ค๋ ๋คํ์ ๋๋ค! ์ ๋ง ๊ฐ๋จํฉ๋๋ค. cordova-custom-config ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ๋ฉด ๊ฐ ํ๋ซํผ(Info.plist / AndroidManifest.xml)์ ๋ํ Cordova์ ์ต์ข ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ config-file ๋ธ๋ก์์ Android์ฉ ํ๋ฌ๊ทธ์ธ ๊ตฌ์ฑ์ "notification_icon"์ด๋ผ๋ ์ ์ด๋ฆ์ผ๋ก ๋๋ก์ด๋ธ ๋๋ ํ ๋ฆฌ์์ "default_notification_icon"์ ๊ฒ์ํ๋๋ก ์ง์ํฉ๋๋ค(ํ๋ฌ๊ทธ์ธ์ด ํ์ผ ํ์ฅ์๋ฅผ ์ ๊ธฐ์ตํ๋ค๋ฉด). ๊ทธ๋ฐ ๋ค์ ๋ค์ ๋ธ๋ก(๋นจ๊ฐ์)์์ ๋ฐฐ๊ฒฝ์์ ์ ์ํฉ๋๋ค. ์ด์ ๋น๋ ์๊ฐ์ ์ฌ๋ฐ๋ฅธ ์์น์ ํด๋น ํ์ผ(notification_icon.png)์ ๊ฐ์ ธ์ค๋ ๋ฐฉ๋ฒ์ด ํ์ํ๋ฏ๋ก ์ด๋ฅผ ์ํํ๊ธฐ ์ํ ํํฌ๊ฐ ํ์ํฉ๋๋ค. ๊ทธ๊ฒ์ android_custom_resources.js์ ๋๋ค. resources/android/custom/*์ ์๋ ๋ชจ๋ ๊ฒ์ ๊ฐ์ ธ์์ ๋น๋์ ๋๋ก์ด๋ธ ๋๋ ํ ๋ฆฌ์ ๋ฃ์ต๋๋ค(์คํฌ๋ฆฝํธ๋ฅผ ํธ์งํ์ฌ ๋ณ๊ฒฝํ ์ ์์ง๋ง ์ด ์์ ์์๋ ๊ด์ฐฎ์ต๋๋ค). ์ถ๊ฐ ๊ตฌ์ฑ ์คํ์ผ๊ณผ ์ ์ฌํฉ๋๋ค. ์ด styles.xml ํ์ผ์ ๋ง๋ญ๋๋ค. ์์์ ์ ์ํ๊ณ (์ ๋ ์ด๋ฆ์ "๋นจ๊ฐ์"์ผ๋ก ์ง์ ํ์ง๋ง ์ํ๋ ๋๋ก ์ง์ ํ ์ ์์ต๋๋ค.) android_custom_values.js๋ ์ด๋ฅผ ๋น๋๋ ๋๋ ํ ๋ฆฌ "platforms/android/res/values"์ ๋ณต์ฌํฉ๋๋ค. ๋ง์ง๋ง์ผ๋ก config.xml์์ ํน์ ์๊ฐ์ ์คํ๋๋๋ก ์ด๋ฌํ ์คํฌ๋ฆฝํธ๋ฅผ ๋ฐ์ธ๋ฉํฉ๋๋ค. ์ด ์์ ์ ์ํด "after_prepare"๋ฅผ ๋ณต์ฌํด์ผ ํฉ๋๋ค. ์ฆ, Cordova๊ฐ ๋น๋๋ฅผ ์ค๋นํ ํ(๋ค์, ์ ๊ฐ ์ ๊ธฐ์ตํ๋ค๋ฉด... Ionic์ ํจํค์ง ํํฌ ๋ฌธ์์์ ์์ธํ ๋ด์ฉ/์ด๋ฒคํธ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค).
@alexbonhomme ์ ๋ต๋ณ์ด ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค :) https://github.com/arnesson/cordova-plugin-firebase/issues/53#issuecomment -304573222
@shamank ์ ๊ฒฐ์ ์ ๋ถ๋ถ์ ์ผ๋ก ์ ์๊ฒ ํจ๊ณผ์ ์
๋๋ค.
Angular + Cordova๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
android_custom_resources.js๋ ํด๋(drawable-ldpi, drawable-mdpi ๋ฑ)๋ฅผ ์์ฑํ์ง ์์ผ๋ฉฐ ํด๋๊ฐ ์กด์ฌํ์ง ์๋ ๊ฒฝ์ฐ ํ์ผ์ ๋ณต์ฌํ์ง ์์ต๋๋ค.
๊ทธ๋์ ํด๋น ์คํฌ๋ฆฝํธ๋ฅผ ์ ๊ฑฐํ๊ณ config.xml์์ ์ฌ์ฉํ์ต๋๋ค.
์ฐธ๊ณ : ๊ฒฝ๋ก๋ ์ฌ์ฉ์ ์ง์ ๋ณ๊ฒฝ ๋ฐ [email protected]์ผ๋ก ์ธํด ๋ค๋ฅผ ์ ์์ผ๋ฉฐ >์๋ ๋ค๋ฅธ ์์น์ res/
ํด๋๊ฐ ์์ต๋๋ค.
`
<resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-mdpi/notification.png" />
<resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-hdpi/notification.png" />
<resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xhdpi/notification.png" />
<resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xxhdpi/notification.png" />
<resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xxxhdpi/notification.png" />`
์ด์จ๋ @alexbonhomme ์ @shamank ์๊ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
@shamank ์ ์๋ฃจ์
๊ฒฝ๋ก ๋ด๋ถ์ ์๋ Ionic 3(๋ณด๋ค ๊ตฌ์ฒด์ ์ผ๋ก cordova-android@7์ ๊ฒฝ์ฐ)์ ๊ฒฝ์ฐ:
package-hooks/android_custom_resources.js
package-hooks/android_custom_values.js
res
ํด๋๊ฐ ์ง๊ธ platforms/android/app/src/main/
์์ ์๊ธฐ ๋๋ฌธ์ ์
๋ฐ์ดํธ๋ฉ๋๋ค.
package-hooks/android_custom_resources.js
๋ก ์ด๋ํ์ฌ ์
๋ฐ์ดํธ
var platformDir = 'platforms/android';
์๊ฒ
var platformDir = 'platforms/android/app/src/main';
package-hooks/android_custom_values.js
๋ก ์ด๋ํ์ฌ ์
๋ฐ์ดํธ
var platformDir = platforms/android/res/values';
์๊ฒ
var platformDir = 'platforms/android/app/src/main/res/values';
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@blckshrk ๊ฐ์ฌํฉ๋๋ค!! ๋๋ ๋ง์นจ๋ด ๊ทธ๊ฒ์ ์๋ ์์ผฐ์ต๋๋ค!
Ionic v2 ๋ฐ [email protected] ์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ด์จ: 2.2.2
์ฝ๋ฅด๋๋ฐ: 6.5.0
npm: 4.6.1
์ฌ์ฉ์ ์ง์ ๊ตฌ์ฑ ํ๋ฌ๊ทธ์ธ์ ์ค์นํฉ๋๋ค.
$ ionic plugin add cordova-custom-config --fetch --save
https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.js ๋ฐ https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.js ๋ฅผ ๋ค์ด๋ก๋ํ์ญ์์ค. ํ๋ก์ ํธ ๋ฃจํธ์ "package-hooks"(๋๋ ์ํ๋ ๋ชจ๋ ๊ฒ)๋ผ๋ ์ ๋๋ ํ ๋ฆฌ.
package-hooks/android_custom_resources.js
package-hooks/android_custom_values.js
ํ๋ก์ ํธ ๋ฃจํธ(ํ๋ซํผ ๋ด๋ถ ์๋)์ ๋ค์ ๋๋ ํฐ๋ฆฌ์ ํ์ผ์ ๋ง๋ญ๋๋ค.
resources/android/custom/notification_icon.png
resources/android/values/styles.xml
notification_icon.png
๋ Android >= API 21 ์๋ฆผ ์์ด์ฝ์ ๋๋ค. ๋ด ํฌ๊ธฐ๋ 144x144px์ด๋ฉฐ ๋ฉ์ง๊ฒ ๋ณด์ ๋๋ค.styles.xml
์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค.๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ ๋ค์ผ!