Links

Flutter

Android

본 가이드는 Flutter SDK 3.0.0 기준으로 작성되었습니다.
SDK가 지원하는 최소 버전은 Android API 19(Kitkat) 이상입니다.

플러그인 다운로드

1) 플러그인을 다운로드 합니다.
2) 프로젝트 폴더와 같은 경로에 압축을 해제합니다.

플러그인 적용하기

1) 프로젝트 pubspec.yaml 에 'fingerpush_plugin' 을 추가합니다.
fingerpush_plugin 폴더를 상대 경로로 참조하여 추가합니다.
<project>/pubspec.yaml
fingerpush_plugin:
path: ../fingerpush_plugin/
2) 명령어를 실행하여 플러그인을 적용합니다.
flutter pub get

프로젝트 설정하기

1) 핑거푸시 앱 생성 및 FCM 프로젝트 생성은 Android 매뉴얼을 참고바랍니다.
2) gradle 설정
a. 프로젝트 레벨의 build.gradle 에 'com.google.gms:google-services' 라이브러리를 추가합니다.
<project>/build.gradle
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:4.3.10'
}
}
b. 앱 레벨의 build.gradle 하단에 google-services 플러그인을 추가합니다.
<project>/<app-module>/build.gradle
apply plugin: 'com.google.gms.google-services'
3) AndroidManifest 설정
a. allowBackup 값을 false 로 설정합니다.
AndroidManifest.xml
<application
...
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
...
</application>
b. 푸시 수신을 서비스를 추가합니다.
AndroidManifest.xml
<application>
...
<service
android:name="com.fingerpush.fingerpush_plugin.IntentService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
4) MainActivity 설정
인앱푸시를 사용하는 경우 FlutterFragmentActivity 를 상속받습니다.
MainActivity.kt
...
class MainActivity : FlutterFragmentActivity(), MethodCallHandler {
private lateinit var channel: MethodChannel
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
checkPush(intent.extras)
}
// 푸시 읽음 처리
fun checkPush(data: Bundle?) {
if (data != null) {
val jsonObject = JSONObject()
val payload = data.getBundle("payload")
val keys = payload?.keySet()
if (keys != null) {
for (key in keys) {
jsonObject.put(key, payload?.getString(key))
}
channel.invokeMethod("onNotification", jsonObject.toString())
}
}
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
GeneratedPluginRegistrant.registerWith(flutterEngine)
channel = MethodChannel(flutterEngine.dartExecutor, "FingerPushOnNotification")
channel.setMethodCallHandler(this@MainActivity)
}
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
if (call.method.equals("onNotification")) {
checkPush(intent.extras)
}
}
}

Android API Reference

Android API 는 아래 링크에서 확인 할 수 있습니다.

iOS

본 가이드는 Flutter SDK 3.0.0 기준으로 작성되었습니다.
최소 버전 iOS 10 이상

플러그인 다운로드

1) 플러그인을 다운로드 합니다.
2) 프로젝트 폴더와 같은 경로에 압축을 해제합니다.

플러그인 적용하기

1) 프로젝트 pubspec.yaml 에 'fingerpush_plugin' 을 추가합니다.
fingerpush_plugin 폴더를 상대 경로로 참조하여 추가합니다.
<project>/pubspec.yaml
fingerpush_plugin:
path: ../fingerpush_plugin/
2) 명령어를 실행하여 플러그인을 적용합니다.
flutter pub get
3) 프로젝트에 'fingerpush_plugin.dart' import 합니다.
import 'package:fingerpush_plugin/fingerpush_plugin.dart';
4) fingerpush_plugin/example/lib/main.dart 파일을 참고하여 플러그인을 적용합니다.
푸시 테스트시에는 반드시 실제 기기를 사용해주세요.
시뮬레이터에서는 핑거푸시를 통해 푸시 수신 받을 수 없습니다.

프로젝트 설정하기

1) Xcode 로 Bundle Identifier 와 Provisioning 변경해주세요.
2) Capability 에 Background Mode 와 Push Notifications 를 추가해주세요.

iOS API Refeence

iOS API 는 아래 링크에서 확인 할 수 있습니다.