Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
83644ee9
Commit
83644ee9
authored
Oct 17, 2022
by
Kim Jinsung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FCM関連ロジック修正
デバイストークン取得改善 プッシュ通知受信処理開演
parent
d80e4968
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
11 deletions
+76
-11
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/push/ABVFcmListenerService.java
+9
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/push/FcmManager.java
+25
-6
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVAuthenticatedActivity.java
+21
-2
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVLoginActivity.java
+13
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+8
-1
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/push/ABVFcmListenerService.java
View file @
83644ee9
...
...
@@ -8,6 +8,8 @@ import android.content.Intent;
import
android.os.Build
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.RemoteMessage
;
...
...
@@ -19,6 +21,7 @@ import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import
jp.agentec.abook.abv.bl.logic.AbstractLogic
;
import
jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic
;
import
jp.agentec.abook.abv.cl.util.AppUtil
;
import
jp.agentec.abook.abv.cl.util.PreferenceUtil
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.common.activity.ShowPushMessageDailogActivity
;
import
jp.agentec.abook.abv.ui.common.appinfo.AppDefType
;
...
...
@@ -46,6 +49,11 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
}
@Override
public
void
onNewToken
(
@NonNull
String
token
)
{
PreferenceUtil
.
putUserPref
(
this
,
AppDefType
.
UserPrefKey
.
NEED_SEND_TOKEN
,
true
);
}
@Override
public
void
onMessageReceived
(
RemoteMessage
remoteMessage
)
{
Map
<
String
,
String
>
msg
=
remoteMessage
.
getData
();
...
...
@@ -86,7 +94,7 @@ public class ABVFcmListenerService extends FirebaseMessagingService {
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
int
uniqueId
=
(
int
)
System
.
currentTimeMillis
();
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
uniqueId
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
uniqueId
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
|
PendingIntent
.
FLAG_IMMUTABLE
);
notification
=
getNotificationBuilder
(
pendingIntent
,
message
).
setChannelId
(
getApplicationContext
().
getPackageName
()).
build
();
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/push/FcmManager.java
View file @
83644ee9
...
...
@@ -4,26 +4,45 @@ import android.content.Context;
//import com.google.firebase.iid.FirebaseInstanceId;
import
androidx.annotation.NonNull
;
import
com.google.android.gms.tasks.OnCompleteListener
;
import
com.google.android.gms.tasks.Task
;
import
com.google.firebase.messaging.FirebaseMessaging
;
import
jp.agentec.abook.abv.bl.common.Callback
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.cl.util.ThreadUtil
;
import
jp.agentec.abook.abv.launcher.android.R
;
public
class
FcmManager
{
private
static
final
String
TAG
=
"FcmManager"
;
/**
* FcmTokenを返す。ただし、PushMessageの利用なしの場合は、noneIdを返す。
* @param context Context
* @return String
*/
public
static
String
getFcmToken
(
Context
context
)
{
String
fcmToken
;
public
static
void
getFcmToken
(
Context
context
,
final
Callback
resultCallback
)
{
if
(
context
.
getResources
().
getInteger
(
R
.
integer
.
push_message
)
==
1
)
{
fcmToken
=
getFcmTokenWithRetryCount
(
10
);
FirebaseMessaging
.
getInstance
().
getToken
()
.
addOnCompleteListener
(
new
OnCompleteListener
<
String
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
String
>
task
)
{
if
(!
task
.
isSuccessful
())
{
Logger
.
w
(
TAG
,
"Fetching FCM registration token failed"
,
task
.
getException
());
resultCallback
.
callback
(
null
);
return
;
}
// Get new FCM registration token
String
token
=
task
.
getResult
();
resultCallback
.
callback
(
token
);
}
});
}
else
{
fcmToken
=
"noneId"
;
resultCallback
.
callback
(
"noneId"
)
;
}
return
fcmToken
;
}
private
static
String
getFcmTokenWithRetryCount
(
int
retryCount
)
{
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVAuthenticatedActivity.java
View file @
83644ee9
...
...
@@ -31,8 +31,14 @@ import android.widget.LinearLayout;
import
android.widget.PopupWindow
;
import
android.widget.ScrollView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
//import com.google.firebase.iid.FirebaseInstanceId;
import
androidx.annotation.NonNull
;
import
com.google.android.gms.tasks.OnCompleteListener
;
import
com.google.android.gms.tasks.Task
;
import
com.google.firebase.messaging.FirebaseMessaging
;
import
com.google.zxing.WriterException
;
import
org.xwalk.core.XWalkView
;
...
...
@@ -50,6 +56,7 @@ import jp.agentec.abook.abv.bl.acms.type.DownloadStatusType;
import
jp.agentec.abook.abv.bl.acms.type.LoginMode
;
import
jp.agentec.abook.abv.bl.acms.type.UpdateSelect
;
import
jp.agentec.abook.abv.bl.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.Callback
;
import
jp.agentec.abook.abv.bl.common.CommonExecutor
;
import
jp.agentec.abook.abv.bl.common.Constant
;
import
jp.agentec.abook.abv.bl.common.Constant.AlertMessageLevel
;
...
...
@@ -81,6 +88,7 @@ import jp.agentec.abook.abv.bl.logic.MemoLogic;
import
jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic
;
import
jp.agentec.abook.abv.cl.billing.Purchase
;
import
jp.agentec.abook.abv.cl.helper.ABVUncaughtExceptionHandler
;
import
jp.agentec.abook.abv.cl.push.FcmManager
;
import
jp.agentec.abook.abv.cl.util.AndroidStringUtil
;
import
jp.agentec.abook.abv.cl.util.BitmapUtil
;
import
jp.agentec.abook.abv.cl.util.PreferenceUtil
;
...
...
@@ -95,6 +103,7 @@ import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import
jp.agentec.abook.abv.ui.common.constant.ErrorMessage
;
import
jp.agentec.abook.abv.ui.common.constant.NaviConsts
;
import
jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog
;
import
jp.agentec.abook.abv.ui.common.util.ABVToastUtil
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
import
jp.agentec.abook.abv.ui.common.util.DisplayUtil
;
import
jp.agentec.abook.abv.ui.common.util.Initializer
;
...
...
@@ -160,8 +169,18 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
// 更新されてない
return
;
}
// String fcmToken = FirebaseInstanceId.getInstance().getToken();
String
fcmToken
=
"abc"
;
final
Callback
resultCallback
=
new
Callback
()
{
@Override
public
Object
callback
(
Object
ret
)
{
String
fcmToken
=
(
String
)
ret
;
needSendDeviceToken
(
fcmToken
);
return
null
;
}
};
FcmManager
.
getFcmToken
(
this
,
resultCallback
);
}
private
void
needSendDeviceToken
(
String
fcmToken
)
{
boolean
isSendSuccess
=
false
;
// CMSに送信
if
(
getRInteger
(
R
.
integer
.
push_message
)
==
1
&&
fcmToken
!=
null
)
{
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVLoginActivity.java
View file @
83644ee9
...
...
@@ -3,12 +3,15 @@ package jp.agentec.abook.abv.ui.common.activity;
import
android.widget.Toast
;
import
jp.agentec.abook.abv.bl.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.Callback
;
import
jp.agentec.abook.abv.bl.common.exception.ABVException
;
import
jp.agentec.abook.abv.bl.common.log.LogLevel
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.cl.environment.DeviceInfo
;
import
jp.agentec.abook.abv.cl.push.FcmManager
;
import
jp.agentec.abook.abv.cl.util.PreferenceUtil
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.common.appinfo.AppDefType
;
import
jp.agentec.abook.abv.ui.common.util.ABVToastUtil
;
/**
...
...
@@ -24,7 +27,10 @@ public abstract class ABVLoginActivity extends ABVNoAuthenticatedActivity {
* 必要なければユーザ情報を保存する。
*/
protected
void
fcmRegister
()
{
String
fcmToken
=
FcmManager
.
getFcmToken
(
this
);
final
Callback
resultCallback
=
new
Callback
()
{
@Override
public
Object
callback
(
Object
ret
)
{
String
fcmToken
=
(
String
)
ret
;
try
{
if
(
fcmToken
==
null
)
{
Logger
.
w
(
TAG
,
"[fcmRegister]: FCM Token is null."
);
...
...
@@ -41,6 +47,12 @@ public abstract class ABVLoginActivity extends ABVNoAuthenticatedActivity {
}
finally
{
closeProgressPopup
();
}
return
null
;
}
};
FcmManager
.
getFcmToken
(
this
,
resultCallback
);
}
/**
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
View file @
83644ee9
...
...
@@ -105,13 +105,20 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
String
fcmToken
=
FcmManager
.
getFcmToken
(
mContext
);
final
Callback
resultCallback
=
new
Callback
()
{
@Override
public
Object
callback
(
Object
ret
)
{
String
fcmToken
=
(
String
)
ret
;
if
(
fcmToken
==
null
)
{
ABVToastUtil
.
showMakeText
(
mContext
,
R
.
string
.
fcm_not_supported
,
Toast
.
LENGTH_SHORT
);
// FCMトークンを取得できない場合、noneIdでセットしてログインする
fcmToken
=
"noneId"
;
}
noAuthenticatedShowMain
(
isGuestLogin
,
fcmToken
,
urlPath
);
return
null
;
}
};
FcmManager
.
getFcmToken
(
mContext
,
resultCallback
);
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment