Hi all, does this library support hermes on android? I am using version 3.1.1 and i keep getting: Property proxy does not exist, js engine: hermes
It appears not. Since hermes specifically excludes Proxy objects from support: https://github.com/facebook/hermes/blob/master/doc/Features.md#excluded-from-support
Hermes supports Proxy now, yay! Unfortunately it's not quite ready for use yet https://github.com/facebook/hermes/issues/33#issuecomment-576388658
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
I wonder if it is really important to use a Proxy in this library? It does not seem like a crucial functionality.
I just commented out the proxy code in NotificationsIOS and NotificationsAndroid and it works fine. I might make a PR that refactors the code if that's what we want to do.
If proxy is non-essential, excluding it would be great. As mentioned above there has been a build released for hermes that includes proxy, but is not compatible with an available version of RN (no timeline on when that'll be available either).
I wonder if it is really important to use a Proxy in this library? It does not seem like a crucial functionality.
I just commented out the proxy code inNotificationsIOSandNotificationsAndroidand it works fine. I might make a PR that refactors the code if that's what we want to do.
Could you pr edit the code? It would be great to use this library with Hermes
Fixed by adding proxy-polyfill to React Native project package.json and import 'proxy-polyfill' on top of react-native-notifications lib files src/NotificationsAndroid.ts and src/NotificationsIOS.ts, then rebuilding lib's sources and patching lib with patch-package.
If by any change no one will come up with PR I'll fork this and make PR with my changes.
Fixed by adding
proxy-polyfillto React Native projectpackage.jsonandimport 'proxy-polyfill'on top ofreact-native-notificationslib filessrc/NotificationsAndroid.tsandsrc/NotificationsIOS.ts, then rebuilding lib's sources and patching lib withpatch-package.If by any change no one will come up with PR I'll fork this and make PR with my changes.
I'm very sorry, but not understand one thing.. How I can rebuild lib's sources? What should I do for this?
@from74, after you make the changes to src/NotificationsIOS.ts and src/NotificationsAndroid.ts, cd into the package folder in your node_modules and run yarn && yarn build. It will recompile the dist folder with the changes you made in src.
Only after rebuilding the dist folder, should you run npx patch-package react-native-notifications because otherwise the app will continue to compile with the pre-patched code.
@from74, after you make the changes to
src/NotificationsIOS.tsandsrc/NotificationsAndroid.ts, cd into the package folder in yournode_modulesand runyarn && yarn build. It will recompile thedistfolder with the changes you made insrc.Only after rebuilding the
distfolder, should you runnpx patch-package react-native-notificationsbecause otherwise the app will continue to compile with the pre-patched code.
After done all these changes, I have got " Error: Unable to resolve module warnOnce from " error
I can confirm that [email protected] which has proxy support works with this package.
Fixed by adding
proxy-polyfillto React Native projectpackage.jsonandimport 'proxy-polyfill'on top ofreact-native-notificationslib filessrc/NotificationsAndroid.tsandsrc/NotificationsIOS.ts, then rebuilding lib's sources and patching lib withpatch-package.If by any change no one will come up with PR I'll fork this and make PR with my changes.
For those who still have issues – https://github.com/wix/react-native-notifications/pull/553. This approach works in my target project.
@from74, after you make the changes to
src/NotificationsIOS.tsandsrc/NotificationsAndroid.ts, cd into the package folder in yournode_modulesand runyarn && yarn build. It will recompile thedistfolder with the changes you made insrc.
Only after rebuilding thedistfolder, should you runnpx patch-package react-native-notificationsbecause otherwise the app will continue to compile with the pre-patched code.After done all these changes, I have got " Error: Unable to resolve module
warnOncefrom " error
I attempted the change explained above too but then also got the same 'warnOnce' error message. I decided to roll it back so I'm back to the Hermes proxy issue again. Is there a better solution on the horizon?
@gavrichards refer to my previous comment, you can install the Hermes 0.4.2 release candidate which has proxy support. I have this running in production currently.
@owinter86 do you mean we explicitly install hermes-engine to the project package?
@gavrichards @axebelk this issue happens because react-native-notifications looks at [email protected] which has the different package directory of warnOnce (it's under react-native-implementation/util)
I was not able to fix this issue by updating react-native inside react-native-notifications to 0.61.5. It caused another issue. Currently the only way to fix this issue(other than updating hermes-engine which I haven't tested yet) is to remove Proxy. Basically you need to add Platform.OS === 'android' to NotificationAndroid.js and Platform.OS === 'ios' to NotificationIOS.js
Object.defineProperty(exports, "__esModule", { value: true });
const react_native_1 = require("react-native");
class NotificationsIOS {
constructor(commands, eventsRegistry) {
this.commands = commands;
this.eventsRegistry = eventsRegistry;
}
/**
* Request permissions to send remote notifications
*/
registerRemoteNotifications() {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.requestPermissions();
}
return {};
}
/**
* Unregister for all remote notifications received via Apple Push Notification service
*/
abandonPermissions() {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.abandonPermissions();
}
return {};
}
/**
* registerPushKit
*/
registerPushKit() {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.registerPushKit();
}
return {};
}
/**
* getBadgeCount
*/
getBadgeCount() {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.getBadgeCount();
}
return {};
}
/**
* setBadgeCount
* @param count number of the new badge count
*/
setBadgeCount(count) {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.setBadgeCount(count);
}
return {};
}
/**
* cancelAllLocalNotifications
*/
cancelAllLocalNotifications() {
if (react_native_1.Platform.OS === 'ios') {
this.commands.cancelAllLocalNotifications();
}
}
/**
* checkPermissions
*/
checkPermissions() {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.checkPermissions();
}
return {};
}
/**
* removeDeliveredNotifications
* @param identifiers Array of notification identifiers
*/
removeDeliveredNotifications(identifiers) {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.removeDeliveredNotifications(identifiers);
}
return {};
}
/**
* getDeliveredNotifications
*/
getDeliveredNotifications() {
if (react_native_1.Platform.OS === 'ios') {
return this.commands.getDeliveredNotifications();
}
return {};
}
/**
* Obtain the events registry instance
*/
events() {
if (react_native_1.Platform.OS === 'ios') {
return this.eventsRegistry;
}
return {};
}
}
exports.NotificationsIOS = NotificationsIOS;
Object.defineProperty(exports, "__esModule", { value: true });
const react_native_1 = require("react-native");
class NotificationsAndroid {
constructor(commands) {
this.commands = commands;
}
/**
* Refresh FCM token
*/
registerRemoteNotifications() {
if (react_native_1.Platform.OS === 'android') {
this.commands.refreshToken();
}
}
}
exports.NotificationsAndroid = NotificationsAndroid;
@tomoima525 Yep just yarn/npm install it and that’s it, delete your build folder and rebuild.
@owinter86 this might now work, hermes 0.4 might require RN 0.62
I can confirm npm i [email protected] did the trick for me.
The release notes for Hermes 0.5.0 mention it's intended for React Native 0.63.0, so looks like we'll need to wait for that for a proper fix that doesn't require installing Hermes independently in your project, or for this library to be updated with a fix.
I can confirm
npm i [email protected]did the trick for me.The release notes for Hermes 0.5.0 mention it's intended for React Native 0.63.0, so looks like we'll need to wait for that for a proper fix that doesn't require installing Hermes independently in your project, or for this library to be updated with a fix.
So let me try to sum it up:
rm -rf node_modules
npm install [email protected]
npm install
Note: In my case, upgrading to React-Native 0.62 was required in order to make the Proxy work.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
The issue has been closed for inactivity.
@gavrichards refer to my previous comment, you can install the Hermes 0.4.2 release candidate which has proxy support. I have this running in production currently.
We noticed random crashes in production with the rc1.
I can confirm this issue remains in React Native v0.63.0 using react-native-notifications v3.3.4 and outputs ReferenceError: Property 'Proxy' doesn't exist, js engine: hermes
@sarthakpranesh you can use the v5 Hermes engine version with RN version 0.63.X
https://github.com/facebook/hermes/releases/tag/v0.5.2-rc1
or wait for RN 0.64 which will have the new Hermes engine with proxy enabled by default.
@owinter86 I see, thanks for the help :+1:
For RN 0.63 edit package.json like this:
...
"dependencies": {
...
"hermes-engine": "0.5.2-rc1"
...
},
"resolutions": {
...
"react-native/hermes-engine": "0.5.2-rc1"
...
},
...
I'd like to say that using release candidates for something substantial as a JS-engine is not to be advised.
To the people at Wix: Would it be a huge ordeal to refactor out Proxy?
@jpunt Hermes supports proxy now and will be included in react native release 0.64, you can use the beta versions if you are on previous react native versions as per the comments in this thread.
Yeah, my point exactly: When building production level apps, it's unwise to use beta versions of these kinds of foundation libs.
Excellent news that a fix is coming, but I go for a different lib for now 🙂
Most helpful comment
Fixed by adding
proxy-polyfillto React Native projectpackage.jsonandimport 'proxy-polyfill'on top ofreact-native-notificationslib filessrc/NotificationsAndroid.tsandsrc/NotificationsIOS.ts, then rebuilding lib's sources and patching lib withpatch-package.If by any change no one will come up with PR I'll fork this and make PR with my changes.