v4.x general questions - phunware/maas-engagement-ios-sdk GitHub Wiki

How to subscribe to message/geofence events?

Two options:

  1. Implement EngagementDelegate methods to receive events.

  2. Listen to notification with the following names, which are defined in Engagement.swift:

public extension NSNotification.Name {
    /// Enter a geofence
    static let EnteredGeofence = NSNotification.Name("EnteredGeofence")
    /// Exit a geofence
    static let ExitedGeofence = NSNotification.Name("ExitedGeofence")
    /// Start monitoring geofences
    static let StartedMonitoringGeofences = NSNotification.Name("StartedMonitoringGeofences")
    /// Stop monitoring geofences
    static let StoppedMonitoringGeofences = NSNotification.Name("StoppedMonitoringGeofences")
    /// Added geofences
    static let AddedGeofences = NSNotification.Name("AddedGeofences")
    /// Deleted geofences
    static let DeletedGeofences = NSNotification.Name("DeletedGeofences")
    /// Received a message
    static let ReceivedMessage = NSNotification.Name("ReceivedMessage")
    /// Read a message
    static let ReadMessage = NSNotification.Name("ReadMessage")
    /// Deleted a messgage
    static let DeletedMessage = NSNotification.Name("DeletedMessage")
    /// Whenever error occurred
    static let EngagementError = NSNotification.Name("EngagementError")
}

How to get all geofences?

Call PWEngagement.geofences

How to get all messsages?

Call PWEngagement.messages

How to get a message by message identifier?

Two options:

  1. Call PWEngagement.message(for:) for saved message

  2. Call PWEngagement.retrieveMessage(with:completion:) for incoming message

How to mark a message as read?

Call PWEngagement.read(messageId)

How to delete a message?

Call PWEngagement.delete(messageId)