且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Passslot向pass中添加值?

更新时间:2023-12-06 13:43:16

为了让PassSlot能够显示您提供的数据,您需要告诉系统



为此,我们有所谓的占位符系统。它允许您定义任何数量的数据字段,称为占位符,可以在创建传递过程中提供。



创建占位符的最简单的方法,系统在哪里显示数据是通过在模板上写 $ {< placeholder>}的名称。这将自动为您创建一个文本占位符。



为了使您提供的门 14 出现在通行证的右上角,用 $ {gate} 替换模板上的 23



占位符非常灵活,可以在任何地方(条形码,背面和非可见部分)使用它们,您还可以在每个字段中有多个占位符(例如,您可以 PASSENGER $ {firstName} $ {lastName} )。
占位符也可以具有不同的类型,然后是高级用例的文本,在编辑模板时,您可以在占位符选项卡中查看和编辑它们。


I'm integrating Passlot in my app for wallet integration. I'd created new pass type id and added it in Passslot.

I'd created a pass template for type - boarding pass as below,

And in my app, i'm creating the pass with the above template and a dictionary with values,

NSDictionary *values = [NSDictionary dictionaryWithObjectsAndKeys:
                        @"14", @"gate" ,
                        @"India", @"depart" ,
                        @"UAE", @"arrive" ,
                        @"2:25 PM", @"boardingTime",
                        @"Air India", @"flightNewName" ,
                        @"first", @"class",
                        @"7/22", @"date" ,
                        @"name", @"passenger",nil];

[PassSlot createPassFromTemplateWithName:@"Sample" withValues:values andRequestInstallation:self completion:^{
    NSLog(@"Created");
}];

The pass is created, but the values that I'm passing are not there in the pass. It's showing the default values in the pass template.

I'm passing the values in the dictionary input. why it's not coming?

How can I solve it? Please guide me on this.

In order for PassSlot to be able to show your provided data, you need to tell the system where it should appear on the pass.

For this we have our so called placeholder system. It allows you to define any number of data fields, called placeholders, that can be provided during creation of the pass.

The easiest way to create placeholders on the fly and tell the system where to show the data is by writing ${<name of placeholder>} on your template. This will automatically create a text placeholder for you.

So in order for your provided gate 14 from to data to appear on the top right of the pass, replace on the template the 23 with ${gate}. The same you can do with all other provided data as well.

Placeholders are pretty flexible, you can use them anywhere (barcode, backside & non-visible parts) and you can also have multiple placeholders per field (e.g. you could have PASSENGER composed of ${firstName} ${lastName}). Placeholders can also have different types then text for advanced use cases, you can see and edit them in the placeholders tab when you edit the template.