我正在使用https://www.npmjs.com/package/ngx-agora在angular 8中进行视频通话。根据文档,我需要提供如下的APPID static
const agoraConfig: AgoraConfig = {
AppID: '1239021930912039-02193',
};
imports: [
BrowserModule,
NgxAgoraModule.forRoot(agoraConfig)
],
但是我想根据环境从API响应中设置AppId值。如何使用angular的APP_INITIALIZER进行设置?或者还有其他设置方法吗?
使用AOT时提供程序的解决方案不起作用,因为NgxAgoraModule在forRoot中使用'useValue'。
但是您可以稍后在此过程中设置APPID,如下所示:
export const agoraConfig: AgoraConfig = {
AppID: null //setting null here
};
@NgModule({
...
imports: [
...
NgxAgoraModule.forRoot(agoraConfig),
....
],
...
})
export class AppModule { }
然后在您要创建agora客户(您的组件)的地方
// false at the end disabled auto initializing
this.client = this.ngxAgoraService.createClient({mode: 'rtc', codec: 'h264'}, false);
this.client.init('your-agora-APPID');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句