Issue
The type is declared to be a Date (potentially undefined)
// https://github.com/Iterable/react-native-sdk/blob/master/ts/IterableInAppMessage.ts
declare class IterableInAppMessage {
/**
* the ID for the in-app message
*/
readonly messageId: string;
/**
* the campaign ID for this message
*/
readonly campaignId: number;
/**
* when to trigger this in-app
*/
readonly trigger: IterableInAppTrigger;
/**
* when was this message created
*/
readonly createdAt?: Date;
/**
However when i add the following logging:
console.log('=====================================')
console.log(latestInboxMessage?.itbInAppMessage?.createdAt)
console.log(typeof latestInboxMessage.itbInAppMessage.createdAt)
I see that typeof createdAt is a string when logging from Android and a Number when logging from iOS
Android logs:
i included the error that is thrown that's causing my app to crash (android only)
LOG 1720797936904
LOG string
ERROR Error: fromMillis requires a numerical input, but received a string with value 1720797936904
iOS Logs
LOG 1720797936904
LOG number
Investigation (so far)
I'm not sure what is causing the typeof to be different between iOS/Android, however by reading the code it doesn't look like the typing of Date | undefined is correct. dateObject.setUTCMilliseconds returns a Number, not a Date
// https://github.com/Iterable/react-native-sdk/blob/master/ts/IterableInAppMessage.ts#L115
let createdAt = dict["createdAt"]
if (createdAt) {
var dateObject = new Date(0)
createdAt = dateObject.setUTCMilliseconds(createdAt)
}
Issue
The type is declared to be a
Date(potentially undefined)However when i add the following logging:
I see that
typeof createdAtis astringwhen logging from Android and a Number when logging from iOSAndroid logs:
i included the error that is thrown that's causing my app to crash (android only)
iOS Logs
Investigation (so far)
I'm not sure what is causing the typeof to be different between iOS/Android, however by reading the code it doesn't look like the typing of
Date | undefinedis correct.dateObject.setUTCMillisecondsreturns aNumber, not aDate