You must have a registered channel to send events.

I am trying to trigger a custom event and I have followed all the steps from documentation but I have an error "You must have a registered channel to send events." and I can't find any solution for it here is my code

step 1: 




<script type="text/javascript">
!function(n,t,c,e,u){function r(n){try{f=n(u)}catch(t){return h=t,void i(p,t)}i(s,f)}function i(n,t){for(var c=0;c<n.length;c++)d(n[c],t);
}function o(n,t){return h?(d(t,h),l):f?(d(n,f),l):(n&&s.push(n),t&&p.push(t),l)}function a(n){return o(!1,n)}function d(t,c){
n.setTimeout(function(){t(c)},0)}var f,h,s=[],p=[],l={then:o,"catch":a,_setup:r};n[e]=l;var v=t.createElement("script");
v.src=c,v.async=!0,v.id="_uasdk",v.rel=e,t.head.appendChild(v)}(window,document,'https://aswpsdkus.com/notify/v1/ua-sdk.min.js',
'UA', // This value can be changed to use a custom variable name.
{
appKey: 'MY-APP-KEY',

token: 'MY-BEARER-TOKEN',

// Has no effect on secure domains. Only needed if used on an insecure domain.
secureIframeUrl: 'https://your.secure.domain/path/to/web-push-secure-bridge.html'
})
</script>

 

step 2 :

UA.then(function(sdk) {
sdk.register()
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});


const myEvent = new sdk.CustomEvent('Web_DeeplinkReceived');
myEvent.user = user;

myEvent.properties = {id: 3, name: "John Doe"}
myEvent.track()
.catch(err => {
// see validate() below
console.log(err);
})
}).catch(function(err) {
console.log(err)
})

 

this event should occur when a page loads but it fails give this error "You must have a registered channel to send events."

Please tell me what I am missing because that all there is in the docs.
P.S do I have to add service worker too ?


 

 

Didn't find what you were looking for?

New post

Comments

1 comment

  • Hi Imran,

    The Service Worker does have to be included in your site in order for the Push Registration to work properly. Make sure you've included this in the root directory of your site.

    Additionally, do you see any logs/errors/warnings when the sdk.register() call is made?

    0

Please sign in to leave a comment.