当前位置: 首页>>代码示例>>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;未经允许,请勿转载。