I'm fairly new to VueJS. I'm using PusherBeams to send Notifications to a user, but locally and on my staging site, they're not setup as https or a localhost instance.
So what I'm thinking of doing is using my .env files to determine whether or not to load the Beamsclient
As when running locally, beams is throwing an error :
Error: Pusher Beams relies on Service Workers, which only work in secure contexts. Check that your page is being served from localhost/over HTTPS
I am wondering if I can write an IF to use the .env around the beamsClient constant that I'm setting.
Current code is :
<script>
import AppButton from '../components/AppButton';
import AppHeader from '../components/AppHeader';
import AppBackground from "../components/AppBackground";
import ColumnContainer from "../layouts/ColumnContainer";
import * as PusherPushNotifications from "@pusher/push-notifications-web";
const beamsClient = new PusherPushNotifications.Client({
instanceId: 'sasasa',
});
beamsClient
.start()
.then(() => beamsClient.addDeviceInterest('club'))
.then((beamsClient) => beamsClient.getDeviceId())
.then((deviceId) =>
console.log("Successfully registered with Beams. Device ID:", deviceId)
)
.catch(console.error);
export default
{
components: {ColumnContainer, AppButton, AppHeader, AppBackground},
props: ['user']
};
</script>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire