React native Haste模块映射中不存在模块'crypto'
在react native中系紧执行推梁,但收到以下错误 错误:捆绑失败:错误:无法从React native Haste模块映射中不存在模块'crypto',react-native,push-notification,pusher,React Native,Push Notification,Pusher,在react native中系紧执行推梁,但收到以下错误 错误:捆绑失败:错误:无法从PROJECT-DIRECTORY\node\u modules\@pusher\push notifications server\utils.js解析模块crypto:模块加密在Haste模块映射中不存在 有关步骤,请参阅本文档 在我的App.js中,我为通知测试代码添加了完全相同的代码 const PushNotifications = require('@pusher/push-notification
PROJECT-DIRECTORY\node\u modules\@pusher\push notifications server\utils.js解析模块crypto
:模块加密
在Haste模块映射中不存在
有关步骤,请参阅本文档
在我的App.js中,我为通知测试代码添加了完全相同的代码
const PushNotifications = require('@pusher/push-notifications-server');
let pushNotifications = new PushNotifications({
instanceId: 'YOUR_INSTANCE_ID_HERE',
secretKey: 'YOUR_SECRET_KEY_HERE',
});
pushNotifications
.publishToInterests(['hello'], {
fcm: {
notification: {
title: 'Hello World',
body: 'Hello!',
},
},
})
.then(publishResponse => {
console.log('Just published:', publishResponse.publishId);
})
.catch(error => {
console.log('Error:', error);
});
crypto
在react-native项目中不可访问,并且该博客不适用于react-native项目。是否要将推送通知集成到react本机项目中?是。该博客是针对android的,给出的示例是使用Node.js,这也是我在react native中使用的。请参考此日志,您试图在react native项目中使用server SDK@pusher/push notifications server
找到了一个解决方法