2017-09-18 6 views
0

3D Touch Native PluginをIonic 3アプリ3d-touchで使用しています。3Dタッチイオン3:ページを開く方法

3Dタッチメニューからアプリケーションを開いた後にページを開くにはどうすればよいですか?

app.component.ts

私のコード:

this.platform.ready().then(() => { 
    //3d Touch 
    this.threeDeeTouch.isAvailable().then((isAvailable) => { 
    if(isAvailable == true) { 
     let actions: Array<ThreeDeeTouchQuickAction> = [ 
     { 
      type: 'projects', 
      title: 'Projects', 
      iconType: 'Bookmark' 
     }, 
     { 
     type: 'messages', 
      title: 'Messages', 
      iconType: 'Message' 
     }, 
     ]; 
     this.threeDeeTouch.configureQuickActions(actions); 

     this.threeDeeTouch.onHomeIconPressed().subscribe((payload) => { 

     alert(payload.type) ; 

     //!!!!OPEN PAGE!!!! 

     }) ; 
    } 
    }); 
}) ; 

答えて

1

あなたはタブページやタブにリンクされていない他のページに移動しようとしていますか?私が正しい答えをあなたに提供できるように私に知らせてください。しかし、あなたのアプリで、通常のページに移動するには、次の操作を行います。

app.component.tsを

import { ViewChild } from '@angular/core'; 
import { Nav } from 'ionic-angular'; 

export class MyApp { 

    @ViewChild(Nav) nav: Nav; 

constructor(private threeDeeTouch: ThreeDeeTouch) { 

//ThreeD Touch Configuration 
    this.threeDeeTouch.isAvailable().then(isAvailable => console.log('3D Touch available? ' + isAvailable)); 

    this.threeDeeTouch.watchForceTouches() 
     .subscribe(
     (data: ThreeDeeTouchForceTouch) => { 
      console.log('Force touch %' + data.force); 
      console.log('Force touch timestamp: ' + data.timestamp); 
      console.log('Force touch x: ' + data.x); 
      console.log('Force touch y: ' + data.y); 
     } 
    ); 

    let actions: Array<ThreeDeeTouchQuickAction> = [ 
     { 
     type: 'projects', 
     title: 'my projects', 
     subtitle: 'check our projects!', 
     iconType: 'bookmark' 
     }, 
     { 
     type: 'messages', 
     title: 'Messages', 
     subtitle: 'My Messages', 
     iconType: 'message' 
     } 
    ]; 

    this.threeDeeTouch.configureQuickActions(actions); 

    this.threeDeeTouch.onHomeIconPressed().subscribe(
    (payload) => { 
     // returns an object that is the button you presed 
     if (payload.type == 'projects') { 
      this.nav.push(ProjectsPage); 
     } else if (payload.type =='messages') { 
      this.nav.setRoot(MessagesPage); 

     console.log('Pressed the ${payload.title} button') 
     console.log(payload.type) 

    } 
    ) 

    }); 
    } 
関連する問題