[fcm] Some internal JS tweaks
This commit is contained in:
parent
fe095db90d
commit
7b95613ec6
@ -74,7 +74,7 @@ export default class Message {
|
||||
complete(
|
||||
result?: PresentNotificationResultType | RemoteNotificationResultType
|
||||
): void {
|
||||
if (Platform.OS !== 'ios') {
|
||||
if (Platform.OS === 'android') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14,17 +14,18 @@ type NativeRemoteMessage = {
|
||||
};
|
||||
|
||||
export default class RemoteMessage {
|
||||
collapseKey: string | void;
|
||||
data: { [string]: string };
|
||||
messageId: string;
|
||||
messageType: string | void;
|
||||
to: string;
|
||||
ttl: number;
|
||||
_collapseKey: string | void;
|
||||
_data: { [string]: string };
|
||||
_messageId: string;
|
||||
_messageType: string | void;
|
||||
_to: string;
|
||||
_ttl: number;
|
||||
|
||||
constructor() {
|
||||
this.data = {};
|
||||
this.messageId = generatePushID();
|
||||
this.ttl = 3600;
|
||||
this._data = {};
|
||||
// TODO: Is this the best way to generate an ID?
|
||||
this._messageId = generatePushID();
|
||||
this._ttl = 3600;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,8 +33,8 @@ export default class RemoteMessage {
|
||||
* @param collapseKey
|
||||
* @returns {RemoteMessage}
|
||||
*/
|
||||
withCollapseKey(collapseKey: string): RemoteMessage {
|
||||
this.collapseKey = collapseKey;
|
||||
setCollapseKey(collapseKey: string): RemoteMessage {
|
||||
this._collapseKey = collapseKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -42,13 +43,13 @@ export default class RemoteMessage {
|
||||
* @param data
|
||||
* @returns {RemoteMessage}
|
||||
*/
|
||||
withData(data: Object = {}) {
|
||||
setData(data: { [string]: string } = {}) {
|
||||
if (!isObject(data)) {
|
||||
throw new Error(
|
||||
`RemoteMessage:withData expects an object but got type '${typeof data}'.`
|
||||
`RemoteMessage:setData expects an object but got type '${typeof data}'.`
|
||||
);
|
||||
}
|
||||
this.data = data;
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -57,8 +58,8 @@ export default class RemoteMessage {
|
||||
* @param messageId
|
||||
* @returns {RemoteMessage}
|
||||
*/
|
||||
withMessageId(messageId: string): RemoteMessage {
|
||||
this.messageId = messageId;
|
||||
setMessageId(messageId: string): RemoteMessage {
|
||||
this._messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -67,8 +68,8 @@ export default class RemoteMessage {
|
||||
* @param messageType
|
||||
* @returns {RemoteMessage}
|
||||
*/
|
||||
withMessageType(messageType: string): RemoteMessage {
|
||||
this.messageType = messageType;
|
||||
setMessageType(messageType: string): RemoteMessage {
|
||||
this._messageType = messageType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -77,8 +78,8 @@ export default class RemoteMessage {
|
||||
* @param ttl
|
||||
* @returns {RemoteMessage}
|
||||
*/
|
||||
withTtl(ttl: number): RemoteMessage {
|
||||
this.ttl = ttl;
|
||||
setTtl(ttl: number): RemoteMessage {
|
||||
this._ttl = ttl;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -94,12 +95,12 @@ export default class RemoteMessage {
|
||||
}
|
||||
|
||||
return {
|
||||
collapseKey: this.collapseKey,
|
||||
data: this.data,
|
||||
messageId: this.messageId,
|
||||
messageType: this.messageType,
|
||||
to: this.to,
|
||||
ttl: this.ttl,
|
||||
collapseKey: this._collapseKey,
|
||||
data: this._data,
|
||||
messageId: this._messageId,
|
||||
messageType: this._messageType,
|
||||
to: this._to,
|
||||
ttl: this._ttl,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user