NWPushBuilder

public class NWPushBuilder

The Factory of NWPushBase objects to be built locally

  • Sets the date at wich the Local Push will fire

    Declaration

    Swift

    public func setDate(_ date: Date) -> NWPushBuilder

    Parameters

    date

    the fire Date

    Return Value

    itself for chaining purposes

  • Dummy Method for SDK compliance

    Declaration

    Swift

    public func setTitle(_ title: String) -> NWPushBuilder

    Parameters

    title

    the Title

    Return Value

    itself for chaining purposes

  • Sets the Alert body displayed to the user

    Declaration

    Swift

    public func setBody(_ body: String) -> NWPushBuilder

    Parameters

    body

    the alert content

    Return Value

    itself for chaining purposes

  • Sets the Badge counter value

    Declaration

    Swift

    public func setBadgeCounter(_ badge: Int) -> NWPushBuilder

    Parameters

    badge

    the counter integer value

    Return Value

    itself for chaining purposes

  • Sets the sound to be played

    Declaration

    Swift

    public func setSound(_ sound: String) -> NWPushBuilder

    Parameters

    sound

    the sound name

    Return Value

    itself for chaining purposes

  • Sets the custom NWSimpleObject to be carried along with the push

    Declaration

    Swift

    public func setCustomFields(_ cFields: NWSimpleObject) -> NWPushBuilder

    Parameters

    cFields

    the NWSimpleObject

    Return Value

    itself for chaining purposes

  • Sets the URL to be redirected

    Note

    useful only for Push of type URL

    Declaration

    Swift

    public func setUrl(_ url: URL) -> NWPushBuilder

    Parameters

    url

    a URL

    Return Value

    itself for chaining purposes

  • A Local Push cannot be silent

    Attention

    Do not use this method

    Throws

    NWError.PushNotificationError always

    Declaration

    Swift

    public func scheduleLocalBackgroundPush() throws
  • Schedule a push of type standard

    Example of Building a Standard Local Notification

       do {
            try Newton.getSharedInstance()
                .getPushManager()
                .getPushBuilder()
                .setDate(Date())
                .setBadgeCounter(1)
                .setSound("the sound")
                .setCustomFields(NWSimpleObject(fromDictionary: ["aKey" : "aValue"])!)
                .scheduleLocalStandardPush()
        } catch NWError.PushNotificationError(let reason) {
            print("Error in scheduling the Push: \(reason)")
        } catch {
            print("Unknown Error: \(error)")
        }
    

    Throws

    NWError.PushNotificationError if requirements are not met

    Declaration

    Swift

    public func scheduleLocalStandardPush() throws
  • Schedule a push of type url

    Example of Building a Standard Local Notification

       do {
            try Newton.getSharedInstance()
                .getPushManager()
                .getPushBuilder()
                .setDate(Date())
                .setBadgeCounter(1)
                .setSound("the sound")
                .setUrl(URL(string: "https://www.google.it")!)
                .scheduleLocalUrlPush()
        } catch NWError.PushNotificationError(let reason) {
            print("Error in scheduling the Push: \(reason)")
        } catch {
            print("Unknown Error: \(error)")
        }
    

    Throws

    NWError.PushNotificationError if requirements are not met

    Declaration

    Swift

    public func scheduleLocalUrlPush() throws