Header | Pushwoosh.h |
---|
class FPushwooshModule : public IModuleInterface
Provides methods to receive and handle push notifications for iOS and Android.
Example:
void YourComponent::InitPushwoosh()
{
if (FPushwooshModule::IsAvailable())
{
FPushwooshModule::PushRegistrationSucceeded.AddUObject(this, &YourComponent::PushRegistrationSucceeded_Handler);
FPushwooshModule::PushRegistrationError.AddUObject(this, &YourComponent::PushRegistrationError_Handler);
FPushwooshModule::PushAccepted.AddUObject(this, &YourComponent::PushAccepted_Handler);
FPushwooshModule& pushwoosh = FPushwooshModule::Get();
pushwoosh.Initialize();
pushwoosh.RegisterForPushNotifications();
}
}
void YourComponent::PushRegistrationSucceeded_Handler(FString token)
{
// TODO: handle successful registration
}
void YourComponent::PushRegistrationError_Handler(FString error)
{
// TODO: handle push registration error
}
void YourComponent::PushAccepted_Handler(FString data)
{
// TODO: handle push open
}
static FPushwooshRegistrationSuccessDelegate PushRegistrationSucceeded
static FPushwooshRegistrationErrorDelegate PushRegistrationError
static FPushwooshPushAcceptedDelegate PushAccepted
void Initialize()
void RegisterForPushNotifications()
void UnregisterForPushNotifications()
void SetIntTag(FString tagName, int tagValue)
void SetStringTag(FString tagName, FString tagValue)
void SetTags(FString json)
void SetUserId(FString userId)
void PostEvent(FString event, FString attributes)
static FPushwooshRegistrationSuccessDelegate PushRegistrationSucceeded
Push registration success event. Is triggered after successful RegisterForPushNotifications() call.
Parameters:
- FString pushToken - push notification token.
static FPushwooshRegistrationErrorDelegate PushRegistrationError
Push registration error event. Is triggered if RegisterForPushNotifications() method fails.
Parameters:
- FString error - error description.
static FPushwooshPushAcceptedDelegate PushAccepted
Push notification accept event. Is triggered when user taps on push notification.
Parameters:
- FString json - push notification payload in JSON format.
void Initialize()
Initializes plugin with specified Settings (Edit -> Project Settings... -> Plugins -> Pushwoosh). Tells plugin that client is ready to receive PushRegistrationSucceeded, PushRegistrationError and PushAccepted Delegate events. Sends application open statistics. Should be called on every application start before invoking any other module methods.
void RegisterForPushNotifications()
Request push notification registration. This will result in notification permisstion dialog on iOS. If registration succeeds PushRegistrationSucceeded is broadcasted. If registration fails PushRegistrationError is broadcasted.
Note: On iOS it is recommened to set 'UIBackgroundModes: remote-notification' in Into.plist to be able to get push token and register for push notifications regardless of user choice. Also if 'UIBackgroundModes: remote-notification' is not set and user disables push notifications no callback will be invoked.
void UnregisterForPushNotifications()
Unregisters device from push notifications and tells server that device is no longer subscribed.
void SetIntTag(FString tagName, int tagValue)
Associates device with given (tagName, tagValue) pair.
void SetStringTag(FString tagName, FString tagValue)
Associates device with given (tagName, tagValue) pair.
void SetTags(FString json)
Associates device with given tags in JSON format. Multiple tags can be specified in a single request.
Example:
FPushwooshModule& pushwoosh = FPushwooshModule::Get();
pushwoosh.SetTags("{ \"intTag\" : 1, \"stringTag\" : \"2\", \"listTag\" : [ \"3\", \"4\", \"5\" ] }");
void SetUserId(FString userId);
Set User indentifier. This could be Facebook ID, username or email, or any other user ID. This allows data and events to be matched across multiple user devices.
void PostEvent(FString event, FString attributes)
Post events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel. @param event name of the event @param attributes JSON object with additional event parameters
Example:
FPushwooshModule& pushwoosh = FPushwooshModule::Get();
pushwoosh.PostEvent("buttonPressed", "{ \"buttonNumber\" : \"4\", \"buttonLabel\" : \"Banner\" }");