Manos Chorianopoulos

added test code for push notifications

......@@ -103,6 +103,8 @@
- (void)didReceiveNotification:(NSDictionary *)payload;
- (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload;
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload whileAppWasInState:(UIApplicationState)appState;
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure;
- (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;
......
......@@ -1621,6 +1621,12 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload whileAppWasInState:(UIApplicationState)appState {
// return [[Warply sharedService].pushManager checkforLoyaltySDKNotificationPM:payload whileAppWasInState:appState];
// }
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure {
// return [[Warply sharedService].pushManager checkforLoyaltySDKNotificationPM:payload :^(NSNumber *successResponse) {
......
......@@ -163,6 +163,8 @@ typedef enum WLApplicationState : unsigned int{
- (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo;
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo whileAppWasInState:(UIApplicationState)appState;
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure;
/*!
......
......@@ -387,6 +387,104 @@ static const char* jailbreak_apps[] =
}
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo whileAppWasInState:(UIApplicationState)appState
// {
// // 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 (appState == UIApplicationStateActive)
// state = WLApplicationStateActive;
// else if (appState == UIApplicationStateInactive)
// state = WLApplicationStateClosed;
// else
// state = WLApplicationStateBackground;
// // 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:
// {
// NSLog(@"=== WLApplicationStateActive: %u", state);
// NSLog(@"=== userInfo: %@", userInfo);
// NSLog(@"=== userInfo aps: %@", [userInfo objectForKey:@"aps"]);
// NSLog(@"=== userInfo aps alert: %@", [[userInfo objectForKey:@"aps"] objectForKey:@"alert"]);
// UIAlertController * alert = [UIAlertController alertControllerWithTitle:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"] message:@"" preferredStyle:UIAlertControllerStyleAlert];
// UIAlertAction* yesButton = [UIAlertAction
// actionWithTitle:NSLocalizedString(@"Close", @"Warply")
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
// //Handle your yes please button action here
// }];
// UIAlertAction* noButton = [UIAlertAction
// actionWithTitle:NSLocalizedString(@"View", @"Warply")
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
// //Handle no, thanks button
// }];
// [alert addAction:yesButton];
// [alert addAction:noButton];
// UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// alertWindow.rootViewController = [[UIViewController alloc] init];
// alertWindow.windowLevel = UIWindowLevelAlert + 1;
// [alertWindow makeKeyAndVisible];
// [alertWindow.rootViewController presentViewController:alert animated:YES completion:nil];
// // 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:
// {
// WLLOG(@"=== WLApplicationStateBackground: %u", state);
// [self showItem:inboxItem];
// break;
// }
// case WLApplicationStateClosed:
// WLLOG(@"=== WLApplicationStateClosed: %u", state);
// self.pendingItem = inboxItem;
// break;
// }
// return YES;
// }
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure
// {
// // TODO: Check if this guard should be commented
......
......@@ -5769,6 +5769,14 @@ public class swiftApi {
// TEST CODE FOR PUSH
// public func checkForLoyaltySDKNotification(_ payload: [String : Any], _ appState: UIApplication.State) -> Bool {
// let instanceOfMyApi = MyApi()
// return instanceOfMyApi.checkforLoyaltySDKNotification(payload, whileAppWasIn: appState)
// }
// TEST CODE FOR PUSH
// public func checkForLoyaltySDKNotification(_ payload: [String : Any]) -> Bool {
// let instanceOfMyApi = MyApi()
......