从我的服务器上的iOS自定义应用程序中下载PKPass [英] Downloading PKPass in an iOS custom app from my server

查看:188
本文介绍了从我的服务器上的iOS自定义应用程序中下载PKPass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个返回PKPass的服务器.如果我将URL复制到浏览器,则会显示一个通行证(在Mac和iPhone中). 我用来下载通行证的代码如下:

I've setup a server which returns a PKPass. If I copy the URL to the browser, a pass is shown (both in my Mac and in my iPhone). The code I'm using to download the pass is the following one:

NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:kAPIPass]];
if (nil != data) {
    PKPass *pass = [[PKPass alloc] initWithData:data error:nil];
    PKAddPassesViewController *pkvc = [[PKAddPassesViewController alloc] initWithPass:pass];
    pkvc.delegate = self;
    [self presentViewController:pkvc
                       animated:YES
                     completion:^{
                         // Do any cleanup here
                     }
     ];
}

无论如何,当我运行此代码时,出现以下错误:

Anyway, when I run this code I have the following error:

* 由于未捕获的异常"NSInternalInconsistencyException"而终止应用程序,原因:仅支持RGBA或 白色空间,这种方法很容易.'

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only support RGBA or the White color space, this method is a hack.'

我不知道这是什么错误...用Safari下载通行证似乎还行,甚至代码也还行(只有3个简单的行...)有Passkit经验的人可以帮助我吗?

I don't know what is the bug... The pass seems ok when I download it with Safari and even the code seems ok (there are just 3 simple rows...) Someone experienced with Passkit could help me?

编辑:奇怪的是,完全相同的代码正在一个新的新项目中工作

the weird thing is that the exact same code is working in a fresh new project

从AppDelegate删除以下行,删除崩溃,这很奇怪!

EDIT 2: removing the following line from the AppDelegate, remove the crash, that's weird!

[[UINavigationBar appearance] setTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"navbar_bg_gen.png"]]];

推荐答案

所以问题出在AppDelegate中的这一行:

So the problem was this line in the AppDelegate:

[[UINavigationBar appearance] setTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"navbar_bg_gen.png"]]];

在显示通行证的控制器看来,直到我添加存折之前,图像都可以正常工作.

It seems that the image, which work perfectly till I added passbook, is not liked by the controller displaying the pass.

这篇关于从我的服务器上的iOS自定义应用程序中下载PKPass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆