How to launch my app via NFC tag?

后端 未结 3 1305
日久生厌
日久生厌 2021-01-01 10:27

I\'m currently working on porting an app to UWP. The app has a page with a \"Write to NFC\" button. After the user taps it, it waits for an NFC tag and writes a Launch

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 11:02

    Here is a way :

    1. Register a background task and using a NFC trigger
    2. Register your app for uri activation.
    3. Program the backgroundtask to activate when tapped with a NFC tag and then launch the app suing URI schemes

      // Set the recommended app

      var options = new Windows.System.LauncherOptions();
      options.PreferredApplicationPackageFamilyName= "Contoso.URIApp_8wknc82po1e";
      options.PreferredApplicationDisplayName = "Contoso URI Ap";
      
      // Launch the URI and pass in the recommended app 
      // in case the user has no apps installed to handle the URI
      var success = await Windows.System.Launcher.LaunchUriAsync(uriContoso, options);
      

提交回复
热议问题