Manos Chorianopoulos

add checkForLoyaltySDKNotification

......@@ -101,6 +101,7 @@
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
// - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
- (void)didReceiveNotification:(NSDictionary *)payload;
- (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload;
- (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
- (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -1610,6 +1610,12 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
[[Warply sharedService].pushManager didReceiveRemoteNotification:payload whileAppWasInState:WLApplicationStateClosed];
}
// - (BOOL)checkForLoyaltySDKNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state {
- (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload {
return [[Warply sharedService].pushManager checkforLoyaltySDKNotificationPM:payload];
}
- (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken {
[[Warply sharedService].pushManager sendDeviceInfoIfNecessary:newDeviceToken];
......
......@@ -161,6 +161,8 @@ typedef enum WLApplicationState : unsigned int{
*/
- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
- (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo;
/*!
@abstract Application received a Remote Notification.
@discussion This method notifies the WLPushManager that a remote notification was received and passes the data to the didReceiveRemoteNotification:whileAppWasInState: method
......
......@@ -278,6 +278,65 @@ static const char* jailbreak_apps[] =
}
///////////////////////////////////////////////////////////////////////////////
//- (BOOL)checkForLoyaltySDKNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state
- (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo
{
// TODO: Check if this guard should be commented
if ([userInfo valueForKey:@"_a"] == nil) {
// The push was sent from another push service
return NO;
}
// TODO: Check if states are correct, especially from didFinishLaunchingWithOptions
WLApplicationState state;
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
state = WLApplicationStateActive;
else if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive)
state = WLApplicationStateClosed;
else
state = WLApplicationStateBackground;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
WLLOG(@"Did receive push: %@", jsonString);
WLInboxItem *inboxItem = [[WLInboxItem alloc] initWithAttributes:userInfo] ;
// [WLAnalyticsManager logUserReceivedPush:inboxItem];
if (state != WLApplicationStateActive) {
[WLAnalyticsManager logUserEngagedPush:inboxItem];
}
if (inboxItem.action != 0) {
[self.customPushHanlder didReceiveRemoteNotification:userInfo whileAppWasInState:state];
return YES;
}
switch (state) {
case WLApplicationStateActive:
{
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]];
[alert addButtonWithTitle:NSLocalizedString(@"Close", @"Warply")];
[alert addButtonWithTitle:NSLocalizedString(@"View", @"Warply")];
[alert setDelegate:self];
[alert show];
self.pendingItem = inboxItem;
break;
}
case WLApplicationStateBackground:
{
[self showItem:inboxItem];
break;
}
case WLApplicationStateClosed:
self.pendingItem = inboxItem;
break;
}
return YES;
}
///////////////////////////////////////////////////////////////////////////////
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
WLApplicationState warplyAppState;
......
......@@ -5617,6 +5617,13 @@ public class swiftApi {
let instanceOfMyApi = MyApi()
instanceOfMyApi.didReceiveNotification(payload)
}
public func checkForLoyaltySDKNotification(_ payload: [String : Any]) -> Bool {
let instanceOfMyApi = MyApi()
return instanceOfMyApi.checkforLoyaltySDKNotification(payload)
}
public func sendDeviceInfoIfNecessary(_ newDeviceToken: String) -> Void {
......