Fine Network Traffic Control

Request Processing Policies

Braze allows the user the option to 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, Content Cards, and Geofences
    • Requesting new in-app messages
  • 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];
1
Appboy.sharedInstance()?.flushDataAndProcessRequestQueue()

Manual Request Processing

ABKRequestProcessingPolicy enum value: ABKManualRequestProcessing

  • This protocol is the same as Automatic Request Processing EXCEPT:
    • Custom attributes and custom event data is not automatically flushed to the server throughout the user session.
  • Braze will still perform automatic network requests for internal features, such as requesting in-app messages, Liquid Templating in In-App Messages, Geofences, and Location Tracking. For more details, see the ABKRequestProcessingPolicy declaration in Appboy.h. When these internal requests are made, locally stored custom attributes and custom event data may be flushed to the Braze server, depending on request type.

Data can be manually flushed to Braze’s servers at any time using the following method:

1
[[Appboy sharedInstance] flushDataAndProcessRequestQueue];
1
Appboy.sharedInstance()?.flushDataAndProcessRequestQueue()

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 ABKRequestProcessingPolicy enum values defined below:

1
2
3
4
typedef NS_ENUM(NSInteger, ABKRequestProcessingPolicy) {
  ABKAutomaticRequestProcessing,
  ABKManualRequestProcessing
};
1
2
3
4
public enum ABKRequestProcessingPolicy : Int {
    case automaticRequestProcessing
    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];
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 is forcing you to stop background tasks or something similar.

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?
New Stuff!