Fine Network Traffic Control

Request Processing Policies

Braze allows the user the option to finely control network traffic using the following protocols:

Automatic Request Processing

ABKRequestProcessingPolicy enum value: ABKAutomaticRequestProcessing

  • This is the default request policy value.
  • The Braze SDK will automatically handle all server communication, including:
    • Flushing custom events and attributes data to Braze’s servers
    • Updating the News Feed
    • Requesting new in-app messages
    • Posting feedback
  • Immediate server requests are performed when user-facing data is required for any of Braze’s features, such as in-app messages.
  • To minimize server load, Braze performs periodic flushes of new user data every few seconds.
  • Data can be manually flushed to Braze’s servers at any time using the following method:

    1
    
      [[Appboy sharedInstance] flushDataAndProcessRequestQueue];
    

Automatic Request Processing Except For Custom Event/Attribute Data Flushing

ABKRequestProcessingPolicy enum value: ABKAutomaticRequestProcessingExceptForDataFlush

  • This protocol is the same as Automatic Request Processing EXCEPT:
    • Custom attributes and custom event data is not automatically flushed to the server
  • Data can be manually flushed to Braze’s servers at any time using the following method:

    1
    
      [[Appboy sharedInstance] flushDataAndProcessRequestQueue];
    

Manual Request Processing

ABKRequestProcessingPolicy enum value: ABKManualRequestProcessing

This mode is only recommended for advanced use cases. If you’re merely trying to control background flush behavior, consider using ABKAutomaticRequestProcessingExceptForDataFlush.

  • With the exception of network requests required for internal features, all network traffic is manually controlled. No other communication between the Braze servers and the app will happen unless prompted.
  • Standard network requests (e.g., updating the News Feed, flushing custom events and attributes, etc.) are created and added to the network queue. However, server communication will not happen until the following method is called:

    1
    
      [[Appboy sharedInstance] flushDataAndProcessRequestQueue];
    

    Upon calling the above method, queued network requests will be performed and user data flushed immediately.

  • While in Manual Request Processing mode, flushDataAndProcessRequestQueue must be called in order to flush all network-related activity in your app. For example:
    • Setting custom events and attributes
    • Data automatically collected by Braze (e.g., push token, device data)
    • Analytics events such as starting and ending sessions, in-app message impressions, etc.
  • If the queue already contains a flush request for the current user, the new request will be merged into the pre-existing request such that only one request will be executed. This is done to minimize server load without impacting expected SDK behavior.
  • Braze will still perform automatic network requests for internal features, such as Feedback, Liquid Templating in In-App Messages, Geofences, and Location Tracking. For more details, see the ABKRequestProcessingPolicy declaration in Appboy.h.

Setting the Request Processing Policy

Set Request Policy On Startup

These policies can be set at app startup time from the startWithApiKey:inApplication:withLaunchOptions:withAppboyOptions method. In the appboyOptions dictionary, set the ABKRequestProcessingPolicyOptionKey to any of the following three ABKRequestProcessingPolicy enum values defined below:

1
2
3
4
5
typedef NS_ENUM(NSInteger, ABKRequestProcessingPolicy) {
  ABKAutomaticRequestProcessing,
  ABKAutomaticRequestProcessingExceptForDataFlush,
  ABKManualRequestProcessing
};
1
2
3
4
5
public enum ABKRequestProcessingPolicy : Int {
    case automaticRequestProcessing
    case automaticRequestProcessingExceptForDataFlush
    case manualRequestProcessing
}

Set Request Policy At Runtime

The request processing policy can also be set during runtime via the requestProcessingPolicy property on Appboy. For example:

1
2
// Sets the request processing policy to automatic (the default value)
[Appboy sharedInstance].requestProcessingPolicy = ABKAutomaticRequestProcessing;
1
2
// Sets the request processing policy to automatic (the default value)
Appboy.sharedInstance()!.requestProcessingPolicy = ABKRequestProcessingPolicy.automaticRequestProcessing

Manual Shutdown of In-Flight Server Communication

If at any time an “in-flight” server communication needs to be halted, you must call the following method:

1
[[Appboy sharedInstance] shutdownServerCommunication];

After calling this method, you must reset the request processing mode back to Automatic. For this reason, we only recommend calling this if the OS if forcing you to stop background tasks or something similar.

Policy Regarding Network Requests by the SDK

See the aforementioned enumeration values for more information on possible options. This value can be set at start-up as described above or at runtime.

1
@property (nonatomic, assign) ABKRequestProcessingPolicy requestProcessingPolicy;
Implementation Examples

MiscViewController.m in the Stopwatch sample application provides examples of changing the data request processing policy, as well as manually flushing data to Braze.

WAS THIS PAGE HELPFUL?