當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ionic-native.Push類代碼示例

本文整理匯總了TypeScript中ionic-native.Push的典型用法代碼示例。如果您正苦於以下問題:TypeScript Push類的具體用法?TypeScript Push怎麽用?TypeScript Push使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Push類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: initPush

  initPush() {
    let push = Push.init({
      android: {
        senderID: '1062574085193'
      },
      ios: {
        alert: "true",
        badge: true,
        sound: 'false'
      },
      windows: {}
    });

    push.on('registration', (data) => {
      console.log('id --> notificaciones push ->>', data.registrationId);
    });

    push.on('notification', (data: NotificationEventResponse) => {
      console.log(data.message);
      console.log(data.title);

      //console.log(data.additionalData.card.sections);
      //console.log(data.additionalData.card.sections[0].title);

      //this.conceptService.insertNewCard(data.additionalData.card).subscribe(res => {
      //console.log('this.nav ->', this.nav)

      //this.nav.push(CardDetail, { item: data.additionalData.card })
      //})
    });

    push.on('error', (e) => {
      console.log(e.message);
    });
  }
開發者ID:JorgeSanchezGr,項目名稱:PokeStatus-android,代碼行數:35,代碼來源:home.ts

示例2: alert

 $timeout(function () {
     Splashscreen.hide();
     let push = Push.init({
         ios: {
             alert: "true",
             badge: true,
             sound: 'false'
         }
     });
     push.on('registration', (data) => {
         $http.post("http://192.168.200.169:3001/registrationIds", {registrationId: data.registrationId}).then(function () {
             alert("This device whose registrationId is: " + data.registrationId + " is now registered!");
         }, function (e) {
             alert(JSON.stringify(e));
         });
     });
     push.on('error', (e) => {
         alert(e.message);
     });
 }, 500);
開發者ID:mica16,項目名稱:MyALD2,代碼行數:20,代碼來源:app.ts

示例3: function

     this.platform.ready().then(() => {
        this.push = Push.init({
            android: {
              senderID: "1060313159714"
            },
            ios: {
              alert: "true",
              badge: true,
              sound: 'false'
            },
            windows: {}
          });
          this.push.on('registration', (data) => {
            console.log(data.registrationId);
          });
          this.push.on('notification', (data) => {
            console.log(data);       

            this.push.setApplicationIconBadgeNumber(function() {
              console.log('success');
            }, function() {
              console.log('error');
            }, data.count);

            if (!data.additionalData.foreground){
              this.events.publish('tab:inc');
              this.storage.set('incFromPush',  JSON.stringify({"id": data.additionalData.id, "time": data.additionalData.time}))
              setTimeout(() =>
                this.events.publish('newPush')
              , 100);              
            }

          });
          this.push.on('error', (e) => {
            console.log(e.message);
          });
     });
開發者ID:GECOR,項目名稱:gecor-generic-2016,代碼行數:37,代碼來源:app.ts

示例4: registerForNotification

 // This method takes a Tag object
 registerForNotification(tag: Tag){
     //initialize the push plugin with platform specific config
     let push = Push.init({
         android: {
             senderID: "489646484292"
         },
         ios: {
             alert: "true",
             badge: true,
             sound: 'false'
         },
         windows: {}
     });
     
     // This method will be called when the pugin successfully
     // registers with the native messaging api.
     push.on('registration', (data) => {
         // The registration data object is returned with a platform specific token
         console.log('registration data: ', data);
         
         // Android returns a registrationId string that 
         // needs to be sent to the server.
         console.log(data.registrationId);
         
         // We create the request object, sending a GCM Id and the Tag's id
         let obj = {
             method: 'post',
             body: {
                 gcmRegistrationId: data.registrationId,
                 tag: tag.id
             }
         };
         
         // We are using the Azure App Service library to wrap our
         // RESTful http calls to the server.
         this.azureService.mobileClient.invokeApi('gcmRegistration', obj).then(response =>{
             
             // Once we've registered with the server, we can move that tag 
             // from the tags array to the registeredTags array.
             this.tags.splice(this.tags.indexOf(tag), 1);
             this.registeredTags.push(tag);
         })
     });
     
     // This is the method that will be called when your phone recieves a 
     // push notification. It's possible to incude extra data in the
     // notification so you can route to a page, etc.
     push.on('notification', (data) => {
         console.log(data.message);
         console.log(data.title);
         console.log(data.count);
         console.log(data.sound);
         console.log(data.image);
         console.log(data.additionalData);
     });
     
     // This is error callback for the push-plugin
     push.on('error', (e) => {
         console.log(e.message);
     });
     
 }
開發者ID:justinschuldt,項目名稱:ionicChicagoApp,代碼行數:63,代碼來源:tags.ts


注:本文中的ionic-native.Push類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。