FCM - android 편

eltese·2024년 3월 28일
0
post-thumbnail

1. android > app > src > main > AndroidMenifest.xml에 다음 코드를 추가한다.

(범위가 표기된 코드만 추가하면 된다.)

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.faidems8.floraseojeong">
    <!-- ✨ 요기부터 -->
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    <!-- 요기까지 -->
    
    <application
        ... >
        <activity
            ...
            android:hardwareAccelerated="true"
			<!--  요기부터 -->
            android:turnScreenOn="true"
            android:showWhenLocked="true"
            <!-- 요기까지 -->
            android:windowSoftInputMode="adjustResize">
            ...
            <!-- ✨ 요기부터 -->
            <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value="high_importance_channel"
            />
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- 요기까지 -->
            ...
    </application>
</manifest>

2. android > build.gradle에 다음 코드를 추가한다.

dependencies {
	  // ✨ 요기부터
    classpath 'com.android.tools.build:gradle:7.3.0'
    classpath 'com.google.gms:google-services:4.4.1'
	  // 요기까지  
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

3. android > app > build.gradle에 다음 코드를 추가한다.

dependencies {
	// ✨ 요기부터
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:32.7.2')
    implementation 'com.google.firebase:firebase-analytics'
    // 요기까지

각각의 버전들은 최신 버전을 적용해 주는 것이 좋다.

4. 프로젝트에 googleService 추가하기

Firebase 사이트에 접속해 Messaging > 프로젝트 설정 >

profile
백엔드 주니어 개발자 EL과 앱 개발자 Altese가 함께 운영하는 블로그

0개의 댓글