Foursquare

Urban Airship can easily integrate with Foursquare's Pilgrim SDK by associating channels with Foursquare user identifiers. This allows a single user to be consistently identified across both platforms.

Client Code

Associating the Pilgrim user identifiers with Urban Airship channels can be accomplished with the following code.

iOS

On iOS, associating a Pilgrim user identifier with an Urban Airship channel should be done inside a callback triggered by the UAChannelUpdatedEvent. This is to ensure the channel ID is set immediately once it's available.

// Observe the notification center event `UAChannelUpdatedEvent`
NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.updatePilgrimUserID), name:NSNotification.Name(rawValue:UAChannelUpdatedEvent), object: nil)

// In the notification callback set the userID on your Pilgrim Manager instance
func updatePilgrimUserID() {
     if let channelID = UAirship.push().channelID, let _ = FSQPPilgrimManager.shared().userInfo {
         FSQPPilgrimManager.shared().userInfo!.setUserId(channelID)
     }
 }
// Observe the notification center event `UAChannelUpdatedEvent`
[[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(updateChannel)
                                               name:UAChannelUpdatedEvent
                                             object:nil];

// In the notification callback set the userID on your Pilgrim Manager instance
NSString \*channelID = [[UAirship push] channelID];

if (channelID) {
    [FSQPPilgrimManager.sharedManager.userInfo setUserId:channelID];
}

Android

On Android, associating a Pilgrim user identifier with an Urban Airship channel should be done inside a class extending AirshipReceiver that implements its onChannelCreated function. This is to ensure the channel ID is set immediately once it's available.

private class PilgrimAirshipReceiver extends AirshipReceiver {
    @Override
    protected void onChannelCreated(@NonNull Context context, @NonNull String channelId) {
        PilgrimUserInfo userInfo = new PilgrimUserInfo();
        userInfo.setUserId(channelId);
        PilgrimSdk.get().setUserInfo(userInfo);
    }