Advanced UI Configuration

Disabling Error Alerts

If the error alert messages that the default Socialize UI objects emit do not fit your needs, you can remove them using [Socialize storeUIErrorAlertsDisabled:YES].

In addition, a notification will be posted for all Socialize UI errors.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Socialize storeUIErrorAlertsDisabled:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(errorNotification:) name:SocializeUIControllerDidFailWithErrorNotification object:nil];
    
    return YES;
}

- (void)errorNotification:(NSNotification*)notification {
    NSError *error = [[notification userInfo] objectForKey:SocializeUIControllerErrorUserInfoKey];
    NSLog(@"Error: %@", [error localizedDescription]);
}

Note

The notification will be posted regardless of whether or not you disable error alerts.

Automatic Third Party Linking

v1.6.2 introduces Automatic Authentication for your users. Our data indicates that users who authenticate with a 3rd party (e.g. Twitter or Facebook) are much more likely to introduce new users to your app via the viral effect of activity within your app propagating to these 3rd party networks. From v1.6.3 onwards the Socialize SDK will default to requiring users authenticate with a 3rd party prior to performing any social action (e.g. Comment or Like).

This default behavior can be overridden by the developer (you) with the following settings:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // User can opt out of third party linking (default NO)
    [Socialize storeAnonymousAllowed:YES];
    
    // User is not shown third party link dialog on Social Actions (default NO)
    [Socialize storeAuthenticationNotRequired:YES];
    
    return YES;
}

Standalone Share

v1.7.6 introduces standalone share functionality. This will allow you to add a share button to your app.

Note

This feature was exposed because of high demand, but the share functionality will be changing significantly in Socialize v2.0. The associated will likely be deprecated with the release of v2.0.

@implementation StandaloneShareViewController

- (IBAction)shareButtonPressed:(id)sender {
//    SocializeEntity *entity = [SocializeEntity entityWithKey:@"my_key_or_url" name:@"An Entity"];
//    [Socialize showShareActionSheetWithViewController:self entity:entity success:^{
//        NSLog(@"Share created successfully");
//    } failure:^(NSError *error) {
//        if (![error isSocializeErrorWithCode:SocializeErrorShareCancelledByUser]) {
//            NSLog(@"Share creation failed with error %@", [error localizedDescription]);        
//        }
//    }];
}

@end

Disabling Location

If do not wish for Socialize to ask for the user’s location under any circumstances, you can completely disable location sharing

- (void)disableLocationSharing {
    [Socialize storeLocationSharingDisabled:YES];
}

Overriding Global Display Behavior

For asynchronous events such as notifications, Socialize needs a way to display UI elements to the screen. By default, it will attempt to discover the topmost view controller in the app. If this fails, it will resort to manual UIView management in the application’s root window. Should you need to override this behavior, you can do so by implementing the SZDisplay protocol and returning it dynamically using [SZDisplayUtils setGlobalDisplayBlock:], as below

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // ...
    
    // This example assumes a custom view controller is set as the window's rootViewController property as part of application startup

    [SZDisplayUtils setGlobalDisplayBlock:^id<SZDisplay>{
        UIViewController *controller = self.window.rootViewController;
        while (controller.presentedViewController != nil) {
            controller = controller.presentedViewController;
        }
        return controller;
    }];
    
    // ...
    
    return YES;
}

Note

A default implementation of the SZDisplay protocol for UIViewControllers is provided for you. If you wish, you can also provide your own SZDisplay implementation. See the SZDisplay.h header for the full list of messages you should define.