Note
최신 샘플 및 라이브러리는 아래 링크를 통해, 다운로드 받을 수 있습니다.
Morpheus 플랫폼에서 제공하는 푸시 서비스 중, UPNS 5.1 이하 버전을, UPNS 5.2로 변환하기 위한 문서이다.
Warning
google paly 정책변경으로, targetSDK31 이상 빌드 / 배포 필요
- 신규 앱 : 2022.08. 이후
- 기존 앱 : 2022.11. 이후
targetSDK 31 이상은 Jobdispacher 제약 및 foreground service 제약으로 5.2 마이그레이션이 필요함
라이브러리 교체 (5.1.x >> 5.2.x) : 라이브러리는 샘플 프로젝트에 포함되어 있음.
AndroidManifest.xml 수정
FCM console 에서 google-service.json 파일 다운로드 및 적용
build.gradle 설정
가. exported 추가
<!-- 예시 -->
<activity
android:exported="true"
android:name="com.push.democlient.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
나. receiver exported 추가
<receiver android:name="m.client.push.library.receiver.ServiceHandleReceiver"
android:exported="true">
<intent-filter>
<action android:name="${applicationId}.START_PUSHSERVICE" />
<action android:name="${applicationId}.STOP_PUSHSERVICE" />
<action android:name="${applicationId}.RESTART_PUSHSERVICE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<service android:name="m.client.push.library.service.FCMIntentService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver android:name="com.push.democlient.receiver.MessageArrivedReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.UPNS_MESSAGE_ARRIVED" />
<action android:name="${applicationId}.GCM_MESSAGE_ARRIVED" />
</intent-filter>
</receiver>
<receiver android:name="m.client.push.library.receiver.GcmActionReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.ACTION_GCM" />
</intent-filter>
</receiver>
<receiver android:name="m.client.push.library.receiver.UpnsActionReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.ACTION_UPNS" />
</intent-filter>
</receiver>
다. UPNSJobService 삭제 및 UPNSConnectServcie 속성 추가
<!-- 5.2.버전 신규 -->
<service
android:foregroundServiceType="dataSync"
android:name="m.client.push.library.service.UPNSConnectService"
android:exported="false"/>
<!--
push 5.2 삭제
<service
android:name="m.client.push.library.service.UPNSJobService"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
-->
가. google-service.json 다운로드 방법 :
https://support.google.com/firebase/answer/7015592
https://console.firebase.google.com/u/0/
나. 적용 위치 : app/ 또는 module
모피어스 프로젝트의 경우, 프로젝트 root에 저장
android {
---
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
---
}
// jobdispacher 제거 (5.1용)
//implementation 'com.firebase:firebase-jobdispatcher:0.8.6'
// 5.2용 라이브러리 적용
// 필수 start ===================================================
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.firebase:firebase-messaging:23.0.3'
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'androidx.work:work-runtime:2.7.1'
// 필수 end ===================================================
apply plugin 선언(build.gradle 최하단에 위치 해야 함)
apply plugin: 'com.google.gms.google-services'
Warning
Gradle 환경은 예시이므로, 프로젝트 상황에 맞게, 라이브러리 및 라이브러리 버전 재구성 필요
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven {url "https://maven.google.com"}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
repositories {
maven { url 'https://maven.google.com' }
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 31
//buildToolsVersion '29.0.3'
defaultConfig {
applicationId "com.push.democlient"
minSdkVersion 19
targetSdkVersion 31
multiDexEnabled true
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//implementation 'com.firebase:firebase-jobdispatcher:0.8.6'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.firebase:firebase-messaging:23.0.3'
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'androidx.work:work-runtime:2.7.1'
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
}
//반드시, script 맨 하단에 작성 [위치 옮기지 말것 ]
apply plugin: 'com.google.gms.google-services'
Warning
아래와 같이 Error가 발생하는 경우, dependencies 속성이 Gradle 버전과 맞지 않기 때문이므로, implementation 을 compile 로 변경한다.
Error : A problem occurred evaluating project ':app'. > Could not find method implementation() for arguments
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.push.democlient"
android:versionCode="1"
android:versionName="1.0.0">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- 안드로이드 8.0 이상 필수, 라이브러리 버전 4.1.0.7 이상부터 추가된 리시버 등록 시 권한 등록위해 선언 (없으면 앱 디폴트 권한) -->
<permission
android:name="${applicationId}.permission.MPUSH_PERMISSION"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.MPUSH_PERMISSION" />
<!-- 안드로이드 9.0 이상 필수 : targetSdkVersion = 28 이상인 경우 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name="com.push.democlient.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="LoginActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"></activity>
<activity
android:name="SecretMessageActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"></activity>
<activity
android:name="PushMessageActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"></activity>
<activity
android:name="PushDetailActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"></activity>
<activity
android:name="PushListActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"></activity>
<!-- 5.2.버전 신규 -->
<service
android:name="m.client.push.library.service.UPNSConnectService"
android:exported="false"
android:foregroundServiceType="dataSync" />
<!--
push 5.2 삭제
<service
android:name="m.client.push.library.service.UPNSJobService"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
-->
<receiver
android:name="m.client.push.library.receiver.ServiceHandleReceiver"
android:exported="true">
<intent-filter>
<action android:name="${applicationId}.START_PUSHSERVICE" />
<action android:name="${applicationId}.STOP_PUSHSERVICE" />
<action android:name="${applicationId}.RESTART_PUSHSERVICE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<service
android:name="m.client.push.library.service.FCMIntentService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.push.democlient.receiver.MessageArrivedReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.UPNS_MESSAGE_ARRIVED" />
<action android:name="${applicationId}.GCM_MESSAGE_ARRIVED" />
</intent-filter>
</receiver>
<receiver
android:name="m.client.push.library.receiver.GcmActionReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.ACTION_GCM" />
</intent-filter>
</receiver>
<receiver
android:name="m.client.push.library.receiver.UpnsActionReceiver"
android:exported="false">
<intent-filter>
<action android:name="${applicationId}.ACTION_UPNS" />
</intent-filter>
</receiver>
</application>
</manifest>
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<push>
<receiver>
<file-log>n</file-log>
<log>y</log>
<!-- 라이선스 발급시 별도로 부여 받기 바랍니다.-->
<security-indexes></security-indexes>
<!-- UPMC 서버 버전 -->
<version>5.0</version>
<!-- UPMC server url(필수 설정) -->
<server>http://xxx.xxx.148.97:8080</server>
<timeout>20000</timeout>
<!-- FCM설정 -->
<!-- FCM sender-id (push-type이 GCM/ FCM/ ALL일경우 필수설정) -->
<fcm-sender-id>xxxxxxx</fcm-sender-id>
<!-- 푸쉬타입(필수설정)
GCM:구글GCM / FCM(Public Push)
UPNS:유라클UPNS(Private Push) - 클라이언트 5.1 이상은 ALL 로 적용
ALL : FCM / UPNS 연동시
-->
<android-push-type>ALL</android-push-type>
<!-- 서비스 정책 ,
user : one user multidevice,
device : one user one device,
default : user -->
<policy>device</policy>
<!-- stb(셋탑)/mobile(모바일)/mobile_old(디바이스 아이디 이전 버전) -->
<device-type>mobile</device-type>
<!-- 브로드캐스트 리시버에서 퍼미션 사용 여부를 설정 (Y/N) -->
<use-permission>Y</use-permission>
</receiver>
<upns>
<!-- agent, inapp -->
<agent-service-type>inapp</agent-service-type>
<!-- UPNS RESTART ALARM INTERVAL (초단위) -->
<agent-restart-interval>120</agent-restart-interval>
<!-- auto/manual -->
<agent-receive-confirm>auto</agent-receive-confirm>
</upns>
</push>
</settings>