diff --git a/packages/core/src/platform/env/index.ios.js b/packages/core/src/platform/env/index.ios.js index af2b1c628..7ff89d538 100644 --- a/packages/core/src/platform/env/index.ios.js +++ b/packages/core/src/platform/env/index.ios.js @@ -1,4 +1,4 @@ -import { isNumber, isString } from '@mpxjs/utils' +import { isFunction, isNumber } from '@mpxjs/utils' import { createI18n } from '../builtInMixins/i18nMixin' export function init (Mpx) { @@ -51,9 +51,9 @@ function initGlobalErrorHandling () { const oldOnUnhandledRejection = global.onunhandledrejection global.onunhandledrejection = function onunhandledrejection (event) { onUnhandledRejection(event) - oldOnUnhandledRejection.call(this, event) + isFunction(oldOnUnhandledRejection) && oldOnUnhandledRejection.call(this, event) } - if (global?.HermesInternal?.hasPromise?.()) { + if (global.HermesInternal?.hasPromise?.()) { global.HermesInternal.enablePromiseRejectionTracker?.(rejectionTrackingOptions) } else { require('promise/setimmediate/rejection-tracking').enable(rejectionTrackingOptions)