Skip to content

Handling push result inside your application (iOS)

Introduction

Push message from StreetHawk SDK keeps track of user action to a push notification. Starting release 1/1.6.0, the SDK shares user's action or push results with application . This gives more flexibility to application developers and let them customise the logic for a push notification based on the action taken by the user.

Consider a use case for a Rate App campaign which asks application users to rate your application on App store. While there will be users who are happy to rate the application, there might be few as well who decides the other way. For all those users, application can present the user with a feedback inside the application and get their opinion.

Steps

  • Implement ISHCustomiseHandler
@interface MyHandler : NSObject<ISHCustomiseHandler>

@end
  • Add code in onReceiveResult
@implementation MyHandler

#pragma mark - override functions

- (void)onReceiveResult:(PushDataForApplication *)pushData withResult:(SHResult)result
{
    if (pushData.isAppOnForeground) //UI action only happen when App in FG
    {
        if (pushData.action == SHAction_RateApp && result == SHResult_Decline)
        {
            [StreetHawk shFeedback:@[@"Not like the URL", @"The message is annoying", @"I am busy"] needInputDialog:NO needConfirmDialog:YES withTitle:@"Why decine the message?" withMessage:nil withPushData:nil];
        }
    }
}
  • Register MyHandler instance
MyHandler *handler = [[MyHandler alloc] init];
[StreetHawk shSetCustomiseHandler:handler];

Alternatively if you are developing using Swift,

SHApp.sharedInstance().shSetCustomiseHandler(MyHandler())