5

I'm trying to implement push notifications using the Journey Builder SDK in a Swift Application for iOS with the latest version of the SDK (4.1.0) https://github.com/salesforce-marketingcloud/JB4A-SDK-iOS.

After adding the SDK and creating the Bridging-Header file, I get to use the sdk correctly. However, wen trying to use the method

ETPush.pushManager().configureSDKWithAppID()

I'm only getting Void methods and not Bool as they appear to be in ETPush.h

-(BOOL)configureSDKWithAppID:(NSString *)etAppID
          andAccessToken:(NSString *)accessToken
           withAnalytics:(BOOL)analyticsState
     andLocationServices:(BOOL)locState
           andCloudPages:(BOOL)cpState
         withPIAnalytics:(BOOL)pIAnalyticsState
                   error:(NSError **)configureError;

This is my AppDelegate's didFinishLaunchingWithOptions method:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    //        var error: NSError? = nil
    var successful:Bool? = false

    // Set to YES to enable logging while debugging
    ETPush.setETLoggerToRequiredState(true)

    //USING DEBUG KEYS
    // configure and set initial settings of the JB4ASDK
    do{
        try  successful = ETPush.pushManager().configureSDKWithAppID(kETAppID_Debug, andAccessToken: kETAccessToken_Debug, withAnalytics: true, andLocationServices: true, andCloudPages: true, withPIAnalytics:true)

    }catch{
       print("ERROR")
    }

    if successful != nil{
        if successful == false{
            dispatch_async(dispatch_get_main_queue(), {() -> Void in
                // something failed in the configureSDKWithAppID call - show what the error is

                let alert = UIAlertController(title: "Failed configureSDKWithAppID!", message: "Failed configureSDKWithAppID!", preferredStyle: UIAlertControllerStyle.Alert)
                alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil))
                self.window?.rootViewController?.presentViewController(alert, animated: true, completion: nil)

            })
        }else{

            let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge , .Sound], categories: nil)
            UIApplication.sharedApplication().registerUserNotificationSettings(settings)


            ETPush.pushManager().registerUserNotificationSettings(settings)
            ETPush.pushManager().registerForRemoteNotifications()

            // inform the JB4ASDK of the launch options - possibly UIApplicationLaunchOptionsRemoteNotificationKey or UIApplicationLaunchOptionsLocalNotificationKey
            ETPush.pushManager().applicationLaunchedWithOptions(launchOptions)

            // This method is required in order for location messaging to work and the user's location to be processed
            ETLocationManager.sharedInstance().startWatchingLocation()
        }
    }


    return true
}

I'm getting a "Cannot assign value of type '()' to type 'Bool'" error.

Am I missing something? Shouldn't it return Bool?

I'm not even getting a Bool option with the helper:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.