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) -> NWPushBuilderParameters
datethe fire Date
Return Value
itself for chaining purposes
-
Dummy Method for SDK compliance
Declaration
Swift
public func setTitle(_ title: String) -> NWPushBuilderParameters
titlethe Title
Return Value
itself for chaining purposes
-
Sets the Alert body displayed to the user
Declaration
Swift
public func setBody(_ body: String) -> NWPushBuilderParameters
bodythe alert content
Return Value
itself for chaining purposes
-
Sets the Badge counter value
Declaration
Swift
public func setBadgeCounter(_ badge: Int) -> NWPushBuilderParameters
badgethe counter integer value
Return Value
itself for chaining purposes
-
Sets the sound to be played
Declaration
Swift
public func setSound(_ sound: String) -> NWPushBuilderParameters
soundthe 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) -> NWPushBuilderParameters
cFieldsthe 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) -> NWPushBuilderParameters
urla URL
Return Value
itself for chaining purposes
-
A Local Push cannot be silent
Attention
Do not use this methodThrows
NWError.PushNotificationError alwaysDeclaration
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 metDeclaration
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 metDeclaration
Swift
public func scheduleLocalUrlPush() throws
NWPushBuilder Class Reference