如何在我的Web服務器上生成Pass,然後將其下載到Xcode中。 在xcode上,我試圖生成一個通行證,然後將其添加到我的存摺錢包。代碼:如何在我的Web服務器上生成Pass,然後在Xcode中下載它。
NSString* passFile = @"http://pass.keatonburleson.com/gen.php?name=128keaton";
//3
NSData *passData = [NSData dataWithContentsOfFile:passFile];
//4
NSError* error = nil;
PKPass *newPass = [[PKPass alloc] initWithData:passData
error:&error];
//5
if (error!=nil) {
[[[UIAlertView alloc] initWithTitle:@"Passes error"
message:[error
localizedDescription]
delegate:nil
cancelButtonTitle:@"Ooops"
otherButtonTitles: nil] show];
return;
}
//6
PKAddPassesViewController *addController =
[[PKAddPassesViewController alloc] initWithPass:newPass];
[self presentViewController:addController
animated:YES
completion:nil];
所以基本上,我的錯誤是'痕跡'和崩潰。 更新:感謝Caleb,沒有更多的跟蹤錯誤! 不幸的是,我收到'Pass isnt valid error!' :( 最新更新的代碼:
NSString* passFile = @"http://pass.keatonburleson.com/gen.php?name=128keaton";
NSURL *url = [NSURL URLWithString:passFile];
//3
NSData *passData = [NSData dataWithContentsOfURL:url];
//4
NSError* error = nil;
PKPass *newPass = [[PKPass alloc] initWithData:passData
error:&error];
BG信息:
我的web服務器包含生成passkit通,並顯示下載像PkPass PHP腳本如果你在Mac或iPhone你可以進入passFile的URL,它會顯示一個有效的通行證,我想我的問題是,它試圖下載一個鏈接文件,當它真的產生一個自動下載它時,我可能需要編輯一些服務器代碼, 'saved'pkpass on my webserver。但是,我寧願不這樣做。
你的問題是什麼?我看到的只是一些代碼。我發現你是新來的 - 你應該真正閱讀[faq]來學習如何在這裏有效地提問。 – Caleb