app/scripts/views/ChannelGuide.js
/**
   * Tries to register the application to notify on the given program availability.
   *
   * Note PUSH Notifications don't transfer contextual metadata - it just registers for PUSH
   * TODO Register the programs to track with a separate API - (not in scope of the example).
   *
   * @param {Event} event - The DOM event triggering the action
   * @param {object} program - The program to send the notifications for
   * @return {boolean} false to prevent default DOM event handling & bubbling up
   */
Tries to register the application to notify on the given program availability.
Note PUSH Notifications don't transfer contextual metadata - it just registers for PUSH
TODO Register the programs to track with a separate API - (not in scope of the example).

@param {Event} event - The DOM event triggering the action
@param {object} program - The program to send the notifications for
@return {boolean} false to prevent default DOM event handling & bubbling up
Tries to register the application to notify on the given program availability . Note PUSH Notifications don ' t transfer contextual metadata - it just registers for PUSH TODO Register the programs to track with a separate API - ( not in scope of the example ) . @param { Event } event - The DOM event triggering the action @param { object } program - The program to send the notifications for @return { boolean } false to prevent default DOM event handling & bubbling up
async registerForProgram(event, program) {
    console.log(`Registering customer as subscribef for program ${program.id}`);
    const key = config.notifications.publicKey;
    console.log(`Registering PUSH notifications with key '${key}'`);
    const subscription = await this.swRegistration.pushManager.subscribe({
      userVisibleOnly: true,
      applicationServerKey: ChannelGuide.urlB64ToUint8Array(key),
    });
    await fetch('/api/subscriptions/', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        token: subscription,
        program: program,
      }),
    });
    event.preventDefault ? event.preventDefault() : event.returnValue = false;
    return false;
  }
async registerForProgram ( event , program ) { console . log ( ` ${ program . id } ` ) ; const key = config . notifications . publicKey ; console . log ( ` ${ key } ` ) ; const subscription = await this . swRegistration . pushManager . subscribe ( { userVisibleOnly : true , applicationServerKey : ChannelGuide . urlB64ToUint8Array ( key ) , } ) ; await fetch ( '/api/subscriptions/' , { method : 'POST' , headers : { 'Content-Type' : 'application/json' , } , body : JSON . stringify ( { token : subscription , program : program , } ) , } ) ; event . preventDefault ? event . preventDefault ( ) : event . returnValue = false ; return false ; }
Tries to register the application to notify on the given program availability.
Tries to register the application to notify on the given program availability .
// Register a new subscription (returns the old one if one exists) // TODO Send the PUSH notification to the server // Prevent execution of the other eventhandlers