我有一个发送本地通知的ionic cordova应用程序。我希望本地通知或后台任务触发应用程序进入前台(可能使用@ionic-native/background-mode/ngx和.moveToForeground())。这是sapp和skype在收到呼叫时所做的事情。
目前,当我在本地通知循环中调用函数.moveToForeground()时,没有发生任何事情。
如有任何关于如何进行的指示,将不胜感激。
谢谢你
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { NavigationExtras } from '@angular/router';
import { StorageService, Item } from './services/storage.service';
import { AuthenticationService } from './services/Authentication.service';
import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
import {BackgroundMode} from "@ionic-native/background-mode/ngx";
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private storageService: StorageService,
private authenticationService: AuthenticationService,
private localNotifications: LocalNotifications,
private backgroundMode: BackgroundMode
) {
this.initializeApp();
this.backgroundMode.enable();
setInterval(() =>{
this.groupNotif()
}, 19000);
}
groupNotif() {
this.localNotifications.schedule([
{ id: 0, title: 'Design team meeting' },
{ id: 1, summary: 'me@gmail.com', group: 'email', groupSummary: true },
{ id: 2, title: 'Please take all my money', group: 'email' },
{ id: 3, title: 'A question regarding this plugin', group: 'email' },
{ id: 4, title: 'Wellcome back home', group: 'email' }
]);
this.backgroundMode.unlock();
this.backgroundMode.moveToForeground();
}
1条答案
按热度按时间epggiuax1#
仅在收到推送通知时,不可能在没有用户交互的情况下将应用程序从后台移到前台。
点击通知将使您的应用程序从后台/已删除状态进入前台。
在接到电话时将应用从后台/已删除状态切换到前台是一个特殊情况。Apple允许使用
PushKit
和CallKit
进行VoIP通知。