AWS SNS를 사용하여 SNS 항목과 Device Endpoint 모두에 푸시 알림을 보내고 있습니다. 앱이 실행 중이 아니지만 앱이 실행되는 동안 알림을 표시하지 않는 경우 알림이 표시됩니다.내 Android 앱이 실행 중이더라도 알림을 표시하려고합니다.
알림은 앱 사용자에게 앱의 다른 섹션에서 발생하는 변경 사항을 알려주기 때문에 알림이 표시되므로 앱 준비가되면 체크 아웃 할 수 있습니다. 다른 사람에게 메시지를 입력하는 동안 다른 그룹 채팅에서 새로운 Whatsapp 메시지 알림을받는 것과 같은 것입니다.
다음은 알림 빌더 코드입니다. 모든 힌트는 정말 감사하겠습니다. 감사.
private void displayNotification(final String message) {
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
int requestID = (int) System.currentTimeMillis();
PendingIntent contentIntent = PendingIntent.getActivity(this, requestID, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap large_icon = BitmapFactory.decodeResource(this.getResources(),
R.mipmap.myImage);
// Display a notification with an icon, message as content, and default sound. It also
// opens the app when the notification is clicked.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setLargeIcon(large_icon)
.setContentTitle("My Subject Title")
.setContentText(message)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.setContentIntent(contentIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
}
안녕하세요, 사용자가 앱의 알림 센터에서 알림을 클릭하면이 메소드가 호출됩니다. –
아이콘, 내용으로 메시지 및 기본 소리로 알림을 표시합니다. 또한 알림을 클릭하면 앱이 열립니다. –
그래서 나는 인앱 알림을 받기 위해서는 BroadcastReceiver를 사용하는 것이고 수신 알림을 구독하고 앱이 실행되는 동안 처리 할 수 있다고 생각합니다.이 가이드는 http : //www.androidbegin을 따라갈 수 있습니다. co.kr/tutorial/android-broadcast-receiver-notification-tutorial/ –