我已成功创建 .pkpass 文件,并且 api 成功返回 .pkpass 文件。在 Xamarin 表单中,我使用 API 并尝试将 .pkpass 文件添加到钱包中,但钱包不会自动启动。
通过 Xamarin 应用程序从 api 使用的文件工作正常,文件没有问题。我已将其作为电子邮件附件发送并下载了附件 - .pkpass 文件会自动使用钱包应用程序打开。
public async Task DigitalMembershipCardApple()
{
string accesstoken = _dataHelper.GetAccessTokenFromDBAsync().Result;
try
{
_oHttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accesstoken);
HttpResponseMessage response = await _oHttpClient.GetAsync(new Uri(Constants.Urls.DigitalMembershipCardApple + _dataHelper.GetPersonID()));
byte[] filebytes = await response.Content.ReadAsByteArrayAsync();
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), Constants.CISIMembershipCardFields.FileDownloadName);
if (File.Exists(filePath))
{
File.Delete(filePath);
File.WriteAllBytes(filePath, filebytes);
}
else
{
File.WriteAllBytes(filePath, filebytes);
}
await Launcher.OpenAsync(new OpenFileRequest
{
File = new ReadOnlyFile(filePath, Constants.CISIMembershipCardFields.MimeTypeApple)
});
}
catch (Exception …Run Code Online (Sandbox Code Playgroud) 我已经在 ASP.Net core 支持下成功创建了 Google pay Pass,并且我的其余 api 成功返回了 JWT 令牌。另外,我使用“保存到手机”网络按钮并使用 JWT,工作正常,但我需要将通行证与我的 Xamarin Forms 应用程序集成,在 xamrin 中,我如何添加“保存到手机”按钮以及如何将 JWT 与该按钮绑定?