我正在研究ApiRTC和Ionic 3应用程序,并且遇到以下问题。 我提到了这个example,它是一个单页应用程序。 但是我想在接收各种信号时在页面之间导航。 例如,我在“消息”页面上,假设我收到了来电。 当时,我想转到chatReceivePage。 我的代码实现如下。
消息页面
declare var apiRTC;
export class MessagesPage {
user_data = {};
conversations = [];
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public modalCtrl: ModalController,
public events: Events,
public apirtcProvider: ApiRtcProvider) {
events.subscribe('getUserData_callback', (data) => {
this.conversations = apirtcProvider.conversations;
});
this.apiRTCSessionReadyHandler();
}
apiRTCSessionReadyHandler(){
apiRTC.addEventListener("receiveData" , this.receiveDataHandler);
apiRTC.addEventListener("incomingCall", this.apirtcProvider.incomingCallHandler);
apiRTC.addEventListener("userMediaError", this.apirtcProvider.userMediaErrorHandler);
apiRTC.addEventListener("remoteStreamAdded", this.apirtcProvider.remoteStreamAddedHandler);
apiRTC.addEventListener("userMediaSuccess", this.apirtcProvider.userMediaSuccessHandler);
apiRTC.addEventListener("hangup", this.apirtcProvider.hangupHandler);
}
}
apiRTC提供程序
declare var iosrtc;
declare var apiRTC;
declare var apiCC;
export class ApiRtcProvider {
url = "root_url";
user_main = {}; user_data = {}; conversations = []; friends = [];
conversation_offset: number = 0;
iosrtc: any;
apiRTC : any;
apiCC: any;
distantNumber:any;
webRTCClient:any;
state:any;
constructor(public http: Http,
private event: Events,
public platform: Platform
){
}
apiRTCInit(){
apiRTC.init({
onReady: this.sessionReadyHandler,
apiKey: "APIKEY",
apiCCId : my apiCCID
});
}
sessionReadyHandler(){
console.log("SessionReadyHandler", "api-rtc.ts");
apiRTC = apiRTC;
apiRTC.addEventListener("receiveData" , this.receiveDataHandler);
apiRTC.addEventListener("incomingCall", this.incomingCallHandler);
apiRTC.addEventListener("userMediaError", this.userMediaErrorHandler);
apiRTC.addEventListener("remoteStreamAdded", this.remoteStreamAddedHandler);
apiRTC.addEventListener("userMediaSuccess", this.userMediaSuccessHandler);
apiRTC.addEventListener("hangup", this.hangupHandler);
apiCC = apiCC;
webRTCClient = this.apiCC.session.createWebRTCClient({});
webRTCClient.setUserAcceptOnIncomingCall(true);
}
incomingCallHandler(e) {
this.event.publish('gotoIncomingPage', data);
//Or we can do other things to navigate another pages
//I can't use any data of Ionic at this moment:(
}
}
主要问题是,尽管在IRT提供程序或其他地方定义了 Ionic处理程序(或数据)在apiRTC事件处理程序中未识别。 在触发apiRTC事件后如何导航其他页面? 任何帮助将不胜感激。 谢谢。