Manos Chorianopoulos

add initialisation checks at sendDeviceInfo

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -107,6 +107,7 @@
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure;
- (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
- (BOOL)sdkInitialised;
- (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;
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
......
......@@ -1735,6 +1735,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}
- (BOOL)sdkInitialised {
if ([Warply sharedServiceExists] == YES) {
return YES;
} else {
return NO;
}
}
- (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 {
[[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) {
if (success) {
......
......@@ -6261,8 +6261,25 @@ public class swiftApi {
public func sendDeviceInfoIfNecessary(_ newDeviceToken: String) -> Void {
let instanceOfMyApi = MyApi()
let isInitialised = instanceOfMyApi.sdkInitialised();
if (isInitialised == true) {
instanceOfMyApi.sendDeviceInfoIfNecessary(newDeviceToken)
} else {
instanceOfMyApi.initialize(withCallback: nil, uuid: "0086a2088301440792091b9f814c2267", merchantId: "58763", lang: "el", successBlock: initializeCallback, failureBlock: initializeFailureCallback)
}
func initializeCallback(_ initializeData: [AnyHashable: Any]?) -> Void {
if ((initializeData?["status"] as? Int) == 1) {
instanceOfMyApi.sendDeviceInfoIfNecessary(newDeviceToken)
}
}
func initializeFailureCallback(_ error: Error?) -> Void {
}
}
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 {
......