diff --git a/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts b/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts index 1b23e6e6..738aa42b 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts +++ b/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts @@ -45,8 +45,13 @@ import { OpenProfileOptions } from '@ucap-webmessenger/protocol-buddy'; import { DaesangProtocolService, SmsUtils } from '@ucap-webmessenger/daesang'; import { CallService } from '@ucap-webmessenger/api-prompt'; import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types'; -import { SessionStorageService } from '@ucap-webmessenger/web-storage'; -import { MessageApiService, MessageType } from '@ucap-webmessenger/api-message'; +import { + SessionStorageService, + LocalStorageService +} from '@ucap-webmessenger/web-storage'; +import { MessageType } from '@ucap-webmessenger/api-message'; +import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type'; +import { environment } from '../../../../environments/environment'; @Component({ selector: 'app-page-messenger-main', @@ -74,9 +79,9 @@ export class MainPageComponent implements OnInit, OnDestroy { private store: Store, private ngZone: NgZone, private statusProtocolService: StatusProtocolService, - private messageApiService: MessageApiService, private daesangProtocolService: DaesangProtocolService, private callService: CallService, + private localStorageService: LocalStorageService, private sessionStorageService: SessionStorageService, private dialogService: DialogService, private logger: NGXLogger @@ -137,21 +142,29 @@ export class MainPageComponent implements OnInit, OnDestroy { this.msgOpenMessageSubscription = this.nativeService .msgOpenMessage() .subscribe(messageSeq => { - // unreadCount refresh.. - this.store.dispatch(MessageStore.retrieveUnreadCount({})); + const appUserInfo = this.localStorageService.encGet( + KEY_APP_USER_INFO, + environment.customConfig.appKey + ); - this.ngZone.run(() => { - /** - * 쪽지 상세보기. - * state 를 구독하여 Message.component.ts 에서 팝업 띄움. - */ - this.store.dispatch( - MessageStore.detailMessage({ - messageType: MessageType.Receive, - msgId: Number(messageSeq) - }) - ); - }); + // direct open detail + if (!appUserInfo.settings.notification.receiveForMessage) { + // unreadCount refresh.. + this.store.dispatch(MessageStore.retrieveUnreadCount({})); + + this.ngZone.run(() => { + /** + * 쪽지 상세보기. + * state 를 구독하여 Message.component.ts 에서 팝업 띄움. + */ + this.store.dispatch( + MessageStore.detailMessage({ + messageType: MessageType.Receive, + msgId: Number(messageSeq) + }) + ); + }); + } }); this.loginResSubscription = this.store diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index 6b0b7cf3..6bfc401e 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -210,28 +210,38 @@ export class AppNotificationService { >(KEY_APP_USER_INFO, environment.customConfig.appKey); if (appUserInfo.settings.notification.use) { - const notiReq: NotificationRequest = { - type: NotificationType.Event, - seq: noti.roomSeq, - title: '메세지가 도착했습니다.', - contents: StringUtil.convertFinalEventMessage( - noti.eventType, - noti.message - ), - image: '', - useSound: [ - NotificationMethod.Sound, - NotificationMethod.SoundAndAlert - ].some( - n => n === appUserInfo.settings.notification.method - ) - ? true - : false, - displayTime: - appUserInfo.settings.notification.alertExposureTime * - 1000 - }; - this.nativeService.notify(notiReq); + if ( + appUserInfo.settings.notification.method === + NotificationMethod.Sound + ) { + const audio = new Audio( + 'assets/sounds/messageAlarm.mp3' + ); + audio.play(); + } else { + const notiReq: NotificationRequest = { + type: NotificationType.Event, + seq: noti.roomSeq, + title: '메세지가 도착했습니다.', + contents: StringUtil.convertFinalEventMessage( + noti.eventType, + noti.info.sentMessageJson + ), + image: '', + useSound: [ + NotificationMethod.Sound, + NotificationMethod.SoundAndAlert + ].some( + n => n === appUserInfo.settings.notification.method + ) + ? true + : false, + displayTime: + appUserInfo.settings.notification + .alertExposureTime * 1000 + }; + this.nativeService.notify(notiReq); + } } } } @@ -578,22 +588,43 @@ export class AppNotificationService { >(KEY_APP_USER_INFO, environment.customConfig.appKey); if (appUserInfo.settings.notification.use) { - const notiReq: NotificationRequest = { - type: NotificationType.Message, - seq: noti.keyId, - title: '쪽지가 도착했습니다.', - contents: noti.text, - image: noti.senderInfo.profileImageFile, - useSound: [ - NotificationMethod.Sound, - NotificationMethod.SoundAndAlert - ].some(n => n === appUserInfo.settings.notification.method) - ? true - : false, - displayTime: - appUserInfo.settings.notification.alertExposureTime * 1000 - }; - this.nativeService.notify(notiReq); + if ( + appUserInfo.settings.notification.method === + NotificationMethod.Sound + ) { + const audio = new Audio('assets/sounds/messageAlarm.mp3'); + audio.play(); + } else { + const notiReq: NotificationRequest = { + type: NotificationType.Message, + seq: noti.keyId, + title: '쪽지가 도착했습니다.', + contents: noti.text, + image: noti.senderInfo.profileImageFile, + useSound: [ + NotificationMethod.Sound, + NotificationMethod.SoundAndAlert + ].some( + n => n === appUserInfo.settings.notification.method + ) + ? true + : false, + displayTime: + appUserInfo.settings.notification.alertExposureTime * + 1000 + }; + this.nativeService.notify(notiReq); + } + } + + // direct open detail + if (appUserInfo.settings.notification.receiveForMessage) { + this.store.dispatch( + MessageStore.detailMessage({ + messageType: MessageType.Receive, + msgId: Number(noti.keyId) + }) + ); } } break; diff --git a/projects/ucap-webmessenger-app/src/assets/sounds/messageAlarm.mp3 b/projects/ucap-webmessenger-app/src/assets/sounds/messageAlarm.mp3 new file mode 100644 index 00000000..abaa3831 Binary files /dev/null and b/projects/ucap-webmessenger-app/src/assets/sounds/messageAlarm.mp3 differ diff --git a/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.html b/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.html index ceb7fe41..6b4024ac 100644 --- a/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.html +++ b/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.html @@ -24,13 +24,13 @@ [value]="setting.method" (selectionChange)="onSelectionChangeMethod($event)" > - + 소리 - + 알림창 - + 소리 + 알림창 diff --git a/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.ts b/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.ts index 652a0298..601d4f51 100644 --- a/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.ts +++ b/projects/ucap-webmessenger-ui-settings/src/lib/components/notification.component.ts @@ -13,6 +13,7 @@ import { MatCheckboxChange } from '@angular/material'; import { NGXLogger } from 'ngx-logger'; +import { NotificationMethod } from '@ucap-webmessenger/core'; @Component({ selector: 'ucap-settings-notification', @@ -26,6 +27,8 @@ export class NotificationComponent implements OnInit { @Output() changed = new EventEmitter(); + NotificationMethod = NotificationMethod; + constructor( private changeDetectorRef: ChangeDetectorRef, private logger: NGXLogger