Manos Chorianopoulos

add initialisation checks at sendDeviceInfo

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
107 // TEST CODE FOR PUSH 107 // TEST CODE FOR PUSH
108 // - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure; 108 // - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure;
109 - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken; 109 - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
110 +- (BOOL)sdkInitialised;
110 - (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; 111 - (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;
111 - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 112 - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
112 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority; 113 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
......
...@@ -1735,6 +1735,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1735,6 +1735,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1735 1735
1736 } 1736 }
1737 1737
1738 +- (BOOL)sdkInitialised {
1739 +
1740 + if ([Warply sharedServiceExists] == YES) {
1741 + return YES;
1742 + } else {
1743 + return NO;
1744 + }
1745 +
1746 +}
1747 +
1738 - (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 { 1748 - (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 {
1739 [[Warply sharedService] editProfileWithSuccessBlock:firstname andLastName:lastname andEmail:email andSalutation:salutation andMsisdn:msisdn andNickname:nickname andGender:gender andBirthday:birthday andNameDay:nameday andTaxID:taxid andProfileMetadata:profileMetadata optin:optin newsLetter:newsletter andSMS:sms andSegmentation:segmentation andSMSSegmentation:smsSegmentation :^(NSDictionary *response) { 1749 [[Warply sharedService] editProfileWithSuccessBlock:firstname andLastName:lastname andEmail:email andSalutation:salutation andMsisdn:msisdn andNickname:nickname andGender:gender andBirthday:birthday andNameDay:nameday andTaxID:taxid andProfileMetadata:profileMetadata optin:optin newsLetter:newsletter andSMS:sms andSegmentation:segmentation andSMSSegmentation:smsSegmentation :^(NSDictionary *response) {
1740 if (success) { 1750 if (success) {
......
...@@ -6261,8 +6261,25 @@ public class swiftApi { ...@@ -6261,8 +6261,25 @@ public class swiftApi {
6261 public func sendDeviceInfoIfNecessary(_ newDeviceToken: String) -> Void { 6261 public func sendDeviceInfoIfNecessary(_ newDeviceToken: String) -> Void {
6262 6262
6263 let instanceOfMyApi = MyApi() 6263 let instanceOfMyApi = MyApi()
6264 + let isInitialised = instanceOfMyApi.sdkInitialised();
6265 +
6266 + if (isInitialised == true) {
6267 + instanceOfMyApi.sendDeviceInfoIfNecessary(newDeviceToken)
6268 + } else {
6269 + instanceOfMyApi.initialize(withCallback: nil, uuid: "0086a2088301440792091b9f814c2267", merchantId: "58763", lang: "el", successBlock: initializeCallback, failureBlock: initializeFailureCallback)
6270 + }
6271 +
6272 +
6273 + func initializeCallback(_ initializeData: [AnyHashable: Any]?) -> Void {
6274 + if ((initializeData?["status"] as? Int) == 1) {
6264 instanceOfMyApi.sendDeviceInfoIfNecessary(newDeviceToken) 6275 instanceOfMyApi.sendDeviceInfoIfNecessary(newDeviceToken)
6265 } 6276 }
6277 + }
6278 +
6279 + func initializeFailureCallback(_ error: Error?) -> Void {
6280 + }
6281 +
6282 + }
6266 6283
6267 6284
6268 public func editProfileAsync(firstname: String? = "", lastname: String? = "", email: String? = "", salutation: String? = "", msisdn: String? = "", nickname: String? = "", gender: String? = "", birthday: String? = "", nameday: String? = "", taxid: String? = "", profileMetadata: [String: Any]? = [String: Any](), optin: Bool? = false, newsletter: Bool? = false, sms: Bool? = false, segmentation: Bool? = false, smsSegmentation: Bool? = false, _ editProfileCallback: @escaping (_ editProfileData: VerifyTicketResponseModel?) -> Void) -> Void { 6285 public func editProfileAsync(firstname: String? = "", lastname: String? = "", email: String? = "", salutation: String? = "", msisdn: String? = "", nickname: String? = "", gender: String? = "", birthday: String? = "", nameday: String? = "", taxid: String? = "", profileMetadata: [String: Any]? = [String: Any](), optin: Bool? = false, newsletter: Bool? = false, sms: Bool? = false, segmentation: Bool? = false, smsSegmentation: Bool? = false, _ editProfileCallback: @escaping (_ editProfileData: VerifyTicketResponseModel?) -> Void) -> Void {
......