2017-09-18 4 views
0

Ich benutze 3D Touch Native Plugin in Ionic 3 App 3d-touch.3D Touch Ionic 3: Wie öffne ich die Seite

Wie kann ich die Seite öffnen, nachdem die Anwendung über das 3D Touch Menu geöffnet wurde? In

app.component.ts

mein Code:

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!!!! 

     }) ; 
    } 
    }); 
}) ; 

Antwort

1

Versuchen Sie, auf Registerkarten oder anderen Seiten nicht verknüpft Registerkarten zu navigieren? Lassen Sie es mich wissen, damit ich Ihnen die richtige Antwort geben kann. Aber auf eine normale Seite in Ihrer App navigieren Sie folgendermaßen vorgehen:

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) 

    } 
    ) 

    }); 
    }