Context Examples on

Context Examples

This guide is broken down by vertical and Merchant. For each Merchant is the Context required to render a Button.


Cleaning

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>);
let context: BTNContext = BTNContext.init(subjectLocation: location);
BTNLocation *userLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:userLocation];

Deals

// Coming soon
// Coming soon

Delivery

Restaurant location

let location: BTNLocation = BTNLocation.init(name: "<#RESTAURANT_NAME#>")
location.addIdentifier("<#RESTAURANT_ID", forProvider: "deliveryhero")
let context: BTNContext = BTNContext.init(subjectLocation: location)
BTNLocation *location = [BTNLocation locationWithName:<#RESTAURANT_NAME#>];
[location addIdentifier:@"<#identifier#>" forProvider:@"deliveryhero"];
BTNContext *context = [BTNContext contextWithSubjectLocation:location];

Top restaurants nearby

let location: BTNLocation = BTNLocation.init(latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [BTNLocation locationWithLatitude:<#latitude#>, longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

Subject location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(subjectLocation: location)
BTNLocation *location = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>]
BTNContext *context = [BTNContext contextWithSubjectLocation:location]

Venue ID

For information on how to find the Venue ID, see this guide.

let venue: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
venue.addIdentifier("<#identifier#>", forProvider: "deliverydotcom")
let context: BTNContext = BTNContext.init(subjectLocation: venue)

BTNLocation *venue = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[venue addIdentifier:@"<#identifier#>" forProvider:@"deliverydotcom"];
BTNContext *context = [BTNContext contextWithSubjectLocation:venue];

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:subjectLocation];

Contact us to add this partner.

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *userLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:userLocation];

Venue ID

For information on how to find the Venue ID, see this guide.

let venue: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
venue.addIdentifier("<#RESTAURANT_ID#>", forProvider: "caviar")
let context: BTNContext = BTNContext.init(subjectLocation: venue)
BTNLocation *venue = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[venue addIdentifier:@"<#RESTAURANT_ID#>" forProvider:@"caviar"];
BTNContext *context = [BTNContext contextWithSubjectLocation:venue];

Contact us to add this partner.

Direct link

let context = BTNContext.init()
BTNContext *context = [[BTNContext alloc] init];

Dining

Specific restaurant

For information on how to find the Venue ID, see this guide.

let venue: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
venue.addIdentifier("<#identifier#>", forProvider: "quandoo")
let context: BTNContext = BTNContext.init(subjectLocation: venue)
BTNLocation *venue = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[venue addIdentifier:@"<#identifier#>" forProvider:@"quandoo"];
BTNContext *context = [BTNContext contextWithSubjectLocation:venue];

Top restaurants nearby

let location: BTNLocation = BTNLocation.init(latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [BTNLocation locationWithLatitude:<#latitude#>, longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *userLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:userLocation];

Venue ID

let venue: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
venue.addIdentifier("<#RESTAURANT_ID#>", forProvider: "resy")
let context: BTNContext = BTNContext.init(subjectLocation: venue)
BTNLocation *venue = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[venue addIdentifier:@"<#RESTAURANT_ID#>" forProvider:@"resy"];
BTNContext *context = [BTNContext contextWithSubjectLocation:venue];

Contact us to add this partner.

Specific restaurant

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
location.addIdentifier("<#identifier#>", forProvider: BTNIDProviderOpenTable)
let context: BTNContext = BTNContext.init(subjectLocation: location)
BTNLocation *location = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
[location addIdentifier:@"<#identifier#>" forProvider:BTNIDProviderOpenTable];
BTNContext *context = [BTNContext contextWithSubjectLocation:location];

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *userLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:userLocation];

E-commerce

Contact us to add this partner.

Specific item

let item: BTNItem = BTNItem.init()
item.addIdentifier("<#spring_item_identifier#>", forProvider: "spring")
let context = BTNContext()
context.addCustomValue(item, forContextKey: "item")
BTNItem *item = [[BTNItem alloc] init];
[item addIdentifier:@"<#spring_item_identifier#>" forProvider:@"spring"];
BTNContext *context = [[BTNContext alloc] init];
context[BTNContextItemsKey] = item;

Contact us to add this partner.

For information on how to find the Venue ID, see this guide.

let artistName = BTNMusicArtist(name: "<#artist_name#>")
artistName.addIdentifier("<#artist_identifier#>", forProvider: "itunes")
let context = BTNContext.init(artist: artistName)
BTNMusicArtist *artist = [BTNMusicArtist artistWithName:@"<#artist_name#>"];
[artist addIdentifier:@"<#artist_identifier#>" forProvider:@"itunes"];

Contact us to add this partner.

Direct link

let context = BTNContext.init()
BTNContext *context = [[BTNContext alloc] init];

Contact us to add this partner.

let context = BTNContext.init()
BTNContext *context = [[BTNContext alloc] init];

Contact us to add this partner.

let context = BTNContext.init()
BTNContext *context = [[BTNContext alloc] init];

Contact us to add this partner.

let context = BTNContext.init()
BTNContext *context = [[BTNContext alloc] init];

Contact us to add this partner.

Specific item

For information on how to find the Venue ID, see this guide.

let item: BTNItem = BTNItem.init()
item.addIdentifier("<#jet_item_identifier#>", forProvider: "jet")
let context = BTNContext()
context.addCustomValue(item, forContextKey: "item")
BTNItem *item = [[BTNItem alloc] init];
[item addIdentifier:@"<#jet_item_identifier#>" forProvider:@"jet"];
BTNContext *context = [[BTNContext alloc] init];
context[BTNContextItemsKey] = item;

Health & Beauty

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *userLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:userLocation];

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *userLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:userLocation];

Tickets

Ticketmaster artist name and ID

let location: BTNLocation = BTNLocation.init(latitude: <#latitude#>, longitude: <#longitude#>);
let artist: BTNMusicArtist = BTNMusicArtist.init(artist: "<#Artist Name#>")
let context: BTNContext = BTNContext.init()
context.set(subjectLocation: location)
context.set(artist: artist)
BTNLocation *location = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNMusicArtist *artist = [BTNMusicArtist artistWithName:@"<#Artist Name#>"];
BTNContext *context = [BTNContext context];
[context setSubjectLocation:location];
[context setArtist:artist];

Venue ID

For information on how to find the Venue ID, see this guide.

let venue: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
venue.addIdentifier("<#identifier#>", forProvider: "ticketmaster")
let context: BTNContext = BTNContext.init(subjectLocation: venue)
BTNLocation *venue = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[venue addIdentifier:@"<#identifier#>" forProvider:@"ticketmaster"];
BTNContext *context = [BTNContext contextWithSubjectLocation:venue];

Contact us to add this partner.

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

Transportation

Subject location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(subjectLocation: location)
BTNLocation *subjectLocation = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithSubjectLocation:subjectLocation];

User location

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithUserLocation:subjectLocation];

Subject and user location

let subjectLocation: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let userLocation: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let context: BTNContext = BTNContext.init(subjectLocation: subjectLocation, userLocation: userLocation)
BTNLocation *subjectLocation = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
BTNLocation *userLocation = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
BTNContext *context = [BTNContext contextWithSubjectLocation:subjectLocation, userLocation: userLocation];

let location: BTNLocation = BTNLocation.init(name: "<#Location Name#>", latitude: <#latitude#>, longitude: <#longitude#>)
let event: BTNEvent = BTNEvent.init(startTime: <#startDate#>, endTime: <#endDate#>)
let context: BTNContext = BTNContext.init(event: event, subjectLocation: location)
BTNLocation *location = [BTNLocation locationWithName:@"<#Location Name#>" latitude:<#latitude#> longitude:<#longitude#>];
BTNEvent *event = [BTNEvent eventWithStartTime:<#startDate#> endTime:<#endDate#> location:location];
BTNContext *context = [BTNContext contextWithEvent:event];

Travel

Specific hotel

For information on how to find the Venue ID, see this guide.

let location: BTNLocation = BTNLocation.init()
location.addIdentifier(<#HOTEL_ID#>, forProvider: "hotelsdotcom")
let context: BTNContext = BTNContext.init(subjectLocation: location)
BTNLocation *location = [[BTNLocation alloc] init];
[location addIdentifier:@"<#identifier#>" forProvider:"hotelsdotcom"];
BTNContext *context = [BTNContext contextWithSubjectLocation:location];

User location

let location: BTNLocation = BTNLocation.init()
location.set(name: <#locationName#>)
location.set(city: <#cityName#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [[BTNLocation alloc] init];
[location setName:<#locationName#>];
[location setCity:<#cityName#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

City location

let location: BTNLocation = BTNLocation.init()
location.set(name: <#locationName#>)
location.set(city: <#cityName#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [[BTNLocation alloc] init];
[location setName:<#locationName#>];
[location setCity:<#cityName#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

Contact us to add this partner.

Specific hotel

let location: BTNLocation = BTNLocation.init()
location.addIdentifier(<#HOTEL_ID#>, forProvider: "hoteltonight")
let context: BTNContext = BTNContext.init(subjectLocation: location)
BTNLocation *location = [[BTNLocation alloc] init];
[location addIdentifier:@"<#identifier#>" forProvider:"hoteltonight"];
BTNContext *context = [BTNContext contextWithSubjectLocation:location];

User location

let location: BTNLocation = BTNLocation.init()
location.set(name: <#locationName#>)
location.set(city: <#cityName#>)
let context: BTNContext = BTNContext.init(userLocation: location)
BTNLocation *location = [[BTNLocation alloc] init];
[location setName:<#locationName#>];
[location setCity:<#cityName#>];
BTNContext *context = [BTNContext contextWithUserLocation:location];

Contact us to add this partner.

let journey: BTNJourney = BTNJourney.init()
journey.set(startTime: <#startDate#>)
journey.set(endTime: <#endDate#>)

let startLocation: BTNLocation = BTNLocation.init(latitude: <#latitude#>, longitude: <#longitude#>)
journey.set(startLocation: startLocation)

let destination: BTNLocation = BTNLocation.init(latitude: <#latitude#>, longitude: <#longitude#>)
journey.set(destinationLocation: destination)

let context: BTNContext = BTNContext.init(journey: journey)
}
BTNJourney *journey = [[BTNJourney alloc] init];
[journey setStartTime:<#startDate#>];
[journey setEndTime:<#endDate#>];

BTNLocation *startLocation = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[journey setStartLocation:startLocation];

BTNLocation *destination = [BTNLocation locationWithLatitude:<#latitude#> longitude:<#longitude#>];
[journey setDestinationLocation:destination];

BTNContext *context = [BTNContext contextWithJourney:journey];
}

Load the action for your Button

After the Context is set, load the action for your Button.

// Replace YOUR_BUTTON_ID with your Button ID from the Button Dashboard https://app.usebutton.com
Button.shared().fetchAppAction(withButtonId: "<#YOUR_BUTTON_ID#>", context: context) { appAction, error in
    if appAction != nil {
        self.dropinButton.prepare(with: appAction)
    } else {
        // In the unlikely event of an error, fall back to original action.
    }
}
// Replace YOUR_BUTTON_ID with your Button ID from the Button Dashboard https://app.usebutton.com
[[Button sharedButton] fetchAppActionWithButtonId:@"<#YOUR_BUTTON_ID#>" context:context completion:^(BTNAppAction *appAction, NSError *error) {
    if (appAction) {
        [self.dropinButton prepareWithAppAction:appAction];
    } else {
        // In the unlikely event of an error, fall back to original action.
    }
}];