Showing
5 changed files
with
75 additions
and
0 deletions
| ... | @@ -101,6 +101,7 @@ | ... | @@ -101,6 +101,7 @@ |
| 101 | - (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; | 101 | - (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; |
| 102 | // - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; | 102 | // - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; |
| 103 | - (void)didReceiveNotification:(NSDictionary *)payload; | 103 | - (void)didReceiveNotification:(NSDictionary *)payload; |
| 104 | +- (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload; | ||
| 104 | - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken; | 105 | - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken; |
| 105 | - (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; | 106 | - (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; |
| 106 | - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 107 | - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ... | ... |
| ... | @@ -1610,6 +1610,12 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1610,6 +1610,12 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
| 1610 | [[Warply sharedService].pushManager didReceiveRemoteNotification:payload whileAppWasInState:WLApplicationStateClosed]; | 1610 | [[Warply sharedService].pushManager didReceiveRemoteNotification:payload whileAppWasInState:WLApplicationStateClosed]; |
| 1611 | } | 1611 | } |
| 1612 | 1612 | ||
| 1613 | +// - (BOOL)checkForLoyaltySDKNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state { | ||
| 1614 | +- (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload { | ||
| 1615 | + | ||
| 1616 | + return [[Warply sharedService].pushManager checkforLoyaltySDKNotificationPM:payload]; | ||
| 1617 | +} | ||
| 1618 | + | ||
| 1613 | - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken { | 1619 | - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken { |
| 1614 | 1620 | ||
| 1615 | [[Warply sharedService].pushManager sendDeviceInfoIfNecessary:newDeviceToken]; | 1621 | [[Warply sharedService].pushManager sendDeviceInfoIfNecessary:newDeviceToken]; | ... | ... |
| ... | @@ -161,6 +161,8 @@ typedef enum WLApplicationState : unsigned int{ | ... | @@ -161,6 +161,8 @@ typedef enum WLApplicationState : unsigned int{ |
| 161 | */ | 161 | */ |
| 162 | - (void)didReceiveRemoteNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; | 162 | - (void)didReceiveRemoteNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; |
| 163 | 163 | ||
| 164 | +- (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo; | ||
| 165 | + | ||
| 164 | /*! | 166 | /*! |
| 165 | @abstract Application received a Remote Notification. | 167 | @abstract Application received a Remote Notification. |
| 166 | @discussion This method notifies the WLPushManager that a remote notification was received and passes the data to the didReceiveRemoteNotification:whileAppWasInState: method | 168 | @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[] = | ... | @@ -278,6 +278,65 @@ static const char* jailbreak_apps[] = |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | /////////////////////////////////////////////////////////////////////////////// | 280 | /////////////////////////////////////////////////////////////////////////////// |
| 281 | +//- (BOOL)checkForLoyaltySDKNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state | ||
| 282 | +- (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo | ||
| 283 | +{ | ||
| 284 | + // TODO: Check if this guard should be commented | ||
| 285 | + if ([userInfo valueForKey:@"_a"] == nil) { | ||
| 286 | + // The push was sent from another push service | ||
| 287 | + return NO; | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + // TODO: Check if states are correct, especially from didFinishLaunchingWithOptions | ||
| 291 | + WLApplicationState state; | ||
| 292 | + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) | ||
| 293 | + state = WLApplicationStateActive; | ||
| 294 | + else if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) | ||
| 295 | + state = WLApplicationStateClosed; | ||
| 296 | + else | ||
| 297 | + state = WLApplicationStateBackground; | ||
| 298 | + | ||
| 299 | + | ||
| 300 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:NSJSONWritingPrettyPrinted error:nil]; | ||
| 301 | + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | ||
| 302 | + WLLOG(@"Did receive push: %@", jsonString); | ||
| 303 | + WLInboxItem *inboxItem = [[WLInboxItem alloc] initWithAttributes:userInfo] ; | ||
| 304 | +// [WLAnalyticsManager logUserReceivedPush:inboxItem]; | ||
| 305 | + | ||
| 306 | + if (state != WLApplicationStateActive) { | ||
| 307 | + [WLAnalyticsManager logUserEngagedPush:inboxItem]; | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + if (inboxItem.action != 0) { | ||
| 311 | + [self.customPushHanlder didReceiveRemoteNotification:userInfo whileAppWasInState:state]; | ||
| 312 | + return YES; | ||
| 313 | + } | ||
| 314 | + switch (state) { | ||
| 315 | + case WLApplicationStateActive: | ||
| 316 | + { | ||
| 317 | + UIAlertView *alert = [[UIAlertView alloc] init]; | ||
| 318 | + [alert setTitle:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]; | ||
| 319 | + [alert addButtonWithTitle:NSLocalizedString(@"Close", @"Warply")]; | ||
| 320 | + [alert addButtonWithTitle:NSLocalizedString(@"View", @"Warply")]; | ||
| 321 | + [alert setDelegate:self]; | ||
| 322 | + [alert show]; | ||
| 323 | + | ||
| 324 | + self.pendingItem = inboxItem; | ||
| 325 | + break; | ||
| 326 | + } | ||
| 327 | + case WLApplicationStateBackground: | ||
| 328 | + { | ||
| 329 | + [self showItem:inboxItem]; | ||
| 330 | + break; | ||
| 331 | + } | ||
| 332 | + case WLApplicationStateClosed: | ||
| 333 | + self.pendingItem = inboxItem; | ||
| 334 | + break; | ||
| 335 | + } | ||
| 336 | + return YES; | ||
| 337 | +} | ||
| 338 | + | ||
| 339 | +/////////////////////////////////////////////////////////////////////////////// | ||
| 281 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo | 340 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo |
| 282 | { | 341 | { |
| 283 | WLApplicationState warplyAppState; | 342 | WLApplicationState warplyAppState; | ... | ... |
| ... | @@ -5617,6 +5617,13 @@ public class swiftApi { | ... | @@ -5617,6 +5617,13 @@ public class swiftApi { |
| 5617 | let instanceOfMyApi = MyApi() | 5617 | let instanceOfMyApi = MyApi() |
| 5618 | instanceOfMyApi.didReceiveNotification(payload) | 5618 | instanceOfMyApi.didReceiveNotification(payload) |
| 5619 | } | 5619 | } |
| 5620 | + | ||
| 5621 | + | ||
| 5622 | + public func checkForLoyaltySDKNotification(_ payload: [String : Any]) -> Bool { | ||
| 5623 | + | ||
| 5624 | + let instanceOfMyApi = MyApi() | ||
| 5625 | + return instanceOfMyApi.checkforLoyaltySDKNotification(payload) | ||
| 5626 | + } | ||
| 5620 | 5627 | ||
| 5621 | 5628 | ||
| 5622 | public func sendDeviceInfoIfNecessary(_ newDeviceToken: String) -> Void { | 5629 | public func sendDeviceInfoIfNecessary(_ newDeviceToken: String) -> Void { | ... | ... |
-
Please register or login to post a comment