我需要创建和管理Apple钱包通行证。我正在尝试使用带有ColdFusion的jpasskit。我还想动态创建传递(pass.json文件中每次传递的信息都有变化)。
现在,我正在尝试根据步骤2中的jpasskit教程创建一个主java类来运行代码:
假设我提供了正确的信息: appleWWDRCA privateKeyPath privateKeyPassword
“第2步 使用此命令“git clone https://github.com/drallgood/jpasskit”从github检出Jpasskit或在github上分叉。无论哪种方式都可行。首先使用main方法创建一个简单的java类,然后将此代码粘贴到方法中。“
import java.util.*;
import IPKValidateable.java;
import PKBarcode.java;
import PKBeacon.java;
import PKField.java;
import PKLocation.java;
import PKNFC.java;
import PKPass.java;
import PKPushToken.java;
import PWAssociatedApp.java;
public class mypass
{
ppublic static void main(String[])
{
String appleWWDRCA = "passbook/AppleWWDRCA.pem"; // this is apple's developer relation cert
String privateKeyPath = "./privateKey.p12"; // the private key you exported from keychain
String privateKeyPassword = "password"; // the password you used to export
try {
PKSigningInformation pkSigningInformation = PKSigningUtil.
loadSigningInformationFromPKCS12FileAndIntermediateCertificateFile(
privateKeyPath, privateKeyPassword, appleWWDRCA);
PKPass pass = new PKPass();
pass.setPassTypeIdentifier("pass.com.yourdomain.type");
pass.setAuthenticationToken("vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc");
pass.setSerialNumber("12345678000");
pass.setTeamIdentifier("abcdefg"); // replace this with your team ID
pass.setOrganizationName("your org");
pass.setDescription("some description");
pass.setLogoText("some logo text");
PKBarcode barcode = new PKBarcode();
barcode.setFormat(PKBarcodeFormat.PKBarcodeFormatPDF417);
barcode.setMessageEncoding(Charset.forName("iso-8859-1"));
barcode.setMessage("123456789");
pass.setBarcode(barcode);
PKGenericPass generic = new PKGenericPass();
List<PKField> primaryFields = new ArrayList<PKField>();
PKField member = new PKField();
member.setKey("mykey"); // some unique key for primary field
member.setValue("myvalue"); // some value
primaryFields.add(member);
generic.setPrimaryFields(primaryFields);
pass.setGeneric(generic);
PKLocation location = new PKLocation();
location.setLatitude(37.33182); // replace with some lat
location.setLongitude(-122.03118); // replace with some long
List<PKLocation> locations = new ArrayList<PKLocation>();
locations.add(location);
pass.setLocations(locations);
if (pass.isValid()) {
String pathToTemplateDirectory = "./mypass.raw"; // replace with your folder with the icons
byte[] passZipAsByteArray = PKSigningUtil.
createSignedAndZippedPkPassArchive(pass, pathToTemplateDirectory, pkSigningInformation);
String outputFile = "./mypass.pkpass"; // change the name of the pass
ByteArrayInputStream inputStream = new ByteArrayInputStream(passZipAsByteArray);
IOUtils.copy(inputStream, new FileOutputStream(outputFile));
System.out.println("Done!");
} else {
System.out.println("the pass is NOT Valid man!!!");
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("failed!");
}
}
}
我收到了这些错误:
0:错误:找不到符号 PKSigningInformation pkSigningInformation = PKSigningUtil。 ^ 符号:类PKSigningInformation location:class main
无法找到符号 PKSigningInformation pkSigningInformation = PKSigningUtil。 ^ symbol:变量PKSigningUtil location:class main
我不确定我是否正确创建了主文件。有Java背景的人可以帮忙吗?感谢。