Esempio n. 1
0
 public async Task <IAsyncDisposable> OnBeforeInstallPrompt(Func <BeforeInstallPromptEvent, Task> callback)
 {
     return(await jsRuntime.AddEventListener(
                JsRuntimeObjectRef, "",
                "beforeinstallprompt",
                CallBackInteropWrapper.Create <JsRuntimeObjectRef>(
                    async jsObjectRef =>
     {
         BeforeInstallPromptEvent beforeInstallPromptEvent = new BeforeInstallPromptEvent();
         beforeInstallPromptEvent.Platforms = await jsRuntime.GetInstancePropertyAsync <string[]>(jsObjectRef, "platforms");
         beforeInstallPromptEvent.SetJsRuntime(jsRuntime, jsObjectRef);
         await callback.Invoke(beforeInstallPromptEvent);
     },
                    getJsObjectRef: true,
                    getDeepObject: false
                    )
                ));
 }
Esempio n. 2
0
 /// <summary>
 /// dispatched on devices when a user is about to be prompted to "install" a web application. Its associated event may be saved for later and used to prompt the user at a more suitable time.
 /// </summary>
 /// <param name="callback"></param>
 /// <returns></returns>
 public async ValueTask <IAsyncDisposable> OnBeforeInstallPrompt(
     Func <BeforeInstallPromptEvent, ValueTask> callback)
 {
     return(await JsRuntime.AddEventListener(
                JsObjectRef, "",
                "beforeinstallprompt",
                CallBackInteropWrapper.Create <JsRuntimeObjectRef>(
                    async jsObjectRef =>
     {
         var beforeInstallPromptEvent = new BeforeInstallPromptEvent
         {
             Platforms = await JsRuntime.GetInstanceProperty <string[]>(jsObjectRef, "platforms")
         };
         beforeInstallPromptEvent.SetJsRuntime(JsRuntime, jsObjectRef);
         await callback.Invoke(beforeInstallPromptEvent);
     },
                    getJsObjectRef: true,
                    serializationSpec: false
                    )
                ));
 }