-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MALI-1400] Create interfaces for managing notifications and badge nu…
…mbers (#286) * [MALI-1400] Create interfaces for managing notifications and badge numbers * Prettier fix * Prettier fix
- Loading branch information
1 parent
3104dce
commit 8fc3597
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { PlatformExecutor } from './common-bridge'; | ||
import { | ||
NotificationDetailedInfo, | ||
NotificationInfo, | ||
NotificationInfoType, | ||
} from './types/notification/notification-info'; | ||
|
||
export class NotificationBridge { | ||
executor: PlatformExecutor; | ||
platform: string; | ||
|
||
constructor(executor: PlatformExecutor) { | ||
this.executor = executor; | ||
this.platform = executor.getPlatform(); | ||
} | ||
|
||
/** | ||
* This method is used to clear any notifications in the Host application | ||
* @param {notificationType} NotificationInfoType | ||
* @see {shouldClearNotifications} | ||
*/ | ||
shouldClearNotifications(notificationType: NotificationInfoType) { | ||
return new Promise<string>((resolve, reject) => { | ||
return this.executor.exec( | ||
'shouldClearNotifications', | ||
{ notificationType }, | ||
result => resolve(result), | ||
error => reject(error) | ||
); | ||
}); | ||
} | ||
|
||
/** | ||
* This method is used to to update badge number for a specific notification info | ||
* @param {notificationInfo} NotificationInfo | ||
* @see {shouldUpdateBadgeNumber} | ||
*/ | ||
shouldUpdateBadgeNumber(notificationInfo: NotificationInfo) { | ||
return new Promise<string>((resolve, reject) => { | ||
return this.executor.exec( | ||
'shouldUpdateBadgeNumber', | ||
{ notificationInfo }, | ||
result => resolve(result), | ||
error => reject(error) | ||
); | ||
}); | ||
} | ||
|
||
/** | ||
* This method is used to share the notification detailed information to Host app | ||
* @param {notificationDetailedInfo} NotificationDetailedInfo | ||
* @see {shouldUpdateNotificationInfo} | ||
*/ | ||
shouldUpdateNotificationInfo( | ||
notificationDetailedInfo: NotificationDetailedInfo | ||
) { | ||
return new Promise<string>((resolve, reject) => { | ||
return this.executor.exec( | ||
'shouldUpdateNotificationInfo', | ||
{ notificationDetailedInfo }, | ||
result => resolve(result), | ||
error => reject(error) | ||
); | ||
}); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
js-miniapp-bridge/src/types/notification/notification-info.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export enum NotificationInfoType { | ||
CALLS, | ||
MESSAGES, | ||
HOME, | ||
MAIL, | ||
PROFILE, | ||
SUPPORT, | ||
CUSTOM, | ||
} | ||
|
||
export enum NotificationInfoPriority { | ||
CRITICAL, | ||
MAJOR, | ||
MINOR, | ||
NORMAL, | ||
OFFERS, | ||
MAINTENANCE, | ||
} | ||
|
||
/** | ||
* Notification Info | ||
*/ | ||
export interface NotificationInfo { | ||
badgeNumber?: number; | ||
notificationInfoType?: NotificationInfoType; | ||
notificationInfoPriority?: NotificationInfoPriority; | ||
clearAfterRead?: boolean; | ||
} | ||
|
||
/** | ||
* Notification DetailedInfo | ||
*/ | ||
export interface NotificationDetailedInfo { | ||
title?: string; | ||
body?: string; | ||
icon?: string; | ||
url?: string; | ||
timestamp?: Date; | ||
additionalData?: string; | ||
badgeNumber?: number; | ||
notificationInfoType?: NotificationInfoType; | ||
notificationInfoPriority?: NotificationInfoPriority; | ||
clearAfterRead?: boolean; | ||
} |