Home and Work Detection

After 3-7 days of use the SDK will determine the user’s home and work location. You can see if this has been set by checking the hasHomeOrWork property.

FSQPPilgrimManager.shared().hasHomeOrWork()
    
FrequentLocations.hasHomeOrWork(context)
    

Important: It’s possible that you won’t want to process any visits or only trust visits that have a ‘High’ confidence until home/work has been set. This is due to the fact that a user’s home is not in our venue database, so we may be attributing ‘home’ visits to a venue nearby until we learn that this is in fact their home. An example of this simple check on iOS is below:

func fsqpPilgrimManager(_ locationManager: FSQPPilgrimManager, didVisit visit: FSQPVisit) {
    if FSQPPilgrimManager.shared().hasHomeOrWork() {

        // Home and work are set. Lets print them out
        print(FSQPPilgrimManager.shared().homeLocations)
        print(FSQPPilgrimManager.shared().workLocations)

    } else if visit.confidence != .high {
        // Home and work aren't set and visit confidence isn't High
        // Depending on my application I might not want to trust this visit
    }
}
    

Other Possible Venues

To enable a list of “other venues” to be populated in your arrival events, there is a checkbox on the Pilgrim Console that you can turn on to began to receiving these venues. The venues are alternate places the device may be in order of confidence.

You can access the other places as follows:

func fsqpPilgrimManager(_ locationManager: FSQPPilgrimManager, didVisit visit: FSQPVisit) {
    let otherVenues = visit.otherPossibleVenues
    // Do something with the alternate venues
}
    
protected static final PilgrimNotificationHandler pilgrimNotificationHandler = new PilgrimNotificationHandler() {
    @Override
    public void handlePlaceNotification(Context context, PilgrimSdkPlaceNotification notif) {
        CurrentPlace currentPlace = notif.getCurrentPlace();
        List<Venue> otherVenues = currentPlace.getOtherPossibleVenues();
        // Do something with the alternate venues
    }
}
    

Nearby Venues

You can configure proximity based nearby notifications at a global and user level. For global settings (one’s that apply to all of your users), you can configure those in the Pilgrim console on your developer site. You can read more about configuring global nearby triggers here.

User specific triggers might be useful if you have a specific piece of content that the user requested to be notified about (e.g “Remind me when I’m near the grocery store to get some candy”). You will set a list of NearbyTrigger on the Pilgrim SDK and those will be used on any subsequent stops to check for a match. These can be set and updated at any time.

To set nearby triggers on an individual device:

        var triggers = [FSQPNearbyTrigger]()
        triggers.append(FSQPNearbyTrigger(triggerType: .venue, fsqId: "venueId"))
        triggers.append(FSQPNearbyTrigger(triggerType: .category, fsqId: "categoryId"))
        triggers.append(FSQPNearbyTrigger(triggerType: .chain, fsqId: "chainId"))

        FSQPPilgrimManager.shared().nearbyTriggers = triggers
    
        List<NearbyTrigger> trigs = new ArrayList<>();
        trigs.add(new NearbyTrigger(TriggerPlaceType.CATEGORY, "categoryid"));
        trigs.add(new NearbyTrigger(TriggerPlaceType.CHAIN, "starbuckschainid"));
        trigs.add(new NearbyTrigger(TriggerPlaceType.PLACE, "specificvenueid"));
        PilgrimSdk.get().setNearbyTriggers(trigs);
    

To handle nearby place notifications:

    // Inspect the nearbyVenues property on the visit object in - (void)fsqpPilgrimManager:(FSQPPilgrimManager *)locationManager didVisit:(FSQPVisit *)visit; as follows:
    func fsqpPilgrimManager(_ locationManager: FSQPPilgrimManager, didVisit visit: FSQPVisit) {
        // The `nearbyVenues` property is an array of regular `FSQPVenue`s
        if let nearbyVenues = visit.nearbyVenues {
            for nearbyVenue in nearbyVenues {
                // Handle nearby venue
            }
        }
    }
    
    // Override the other method in PilgrimNotificationHandler as follows:
    protected static final PilgrimNotificationHandler pilgrimNotificationHandler = new PilgrimNotificationHandler() {
        @Override
        public void handlePlaceNotification(Context context, PilgrimSdkPlaceNotification notif) {
        }
        @Override
        public void handleNearbyNotification(Context context, PilgrimSdkNearbyNotification notif) {
            List<NearbyVenue> nearby = notif.getNearbyVenues();
            // A `NearbyVenue` object has a normal `Venue` and a `List<TriggerPlaceType>` that tells you the kind of trigger that it matched. For example, if you were triggering on nearby coffee shops and Starbucks, a Starbucks would be returned with both Chain and Category place types.
        }
    }
    

Venue Harmonization

If you maintain your own venue database, you may want to know if a visit has occurred at one of those venues. We have a guide for venue harmonization in our API documentation, but we can also store a copy of the harmonization and return your venue Id in the Pilgrim visit callback. We enable this on a parter-by-partner basis, please contact us if you feel like this feature should be enabled for you. Once enabled, you will start seeing your venue Ids returned for visits where we have a mapping.

func fsqpPilgrimManager(_ locationManager: FSQPPilgrimManager, didVisit visit: FSQPVisit) {
    let partnerId = visit.venue?.partnerVenueId
    // Do something with your own venue Id
}
    
protected static final PilgrimNotificationHandler pilgrimNotificationHandler = new PilgrimNotificationHandler() {
    @Override
    public void handlePlaceNotification(Context context, PilgrimSdkPlaceNotification notif) {
        String partnerId = notif.getContentId();
        // Do something with your own venue Id
    }
}
    

Next Steps

Check out the Changelog for the latest updates.

Changelog