Skip to content

Commit

Permalink
v13.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Nov 29, 2023
1 parent 1c59d7d commit 262cc88
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 272 deletions.
Binary file modified Example/.DS_Store
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, GleapDelegate {

Gleap.showFeedbackButton(true)

/*Gleap.handlePushNotification([
"type": "news",
"id": "12"
])*/
Gleap.clearIdentity()

/*let userProperty = GleapUserProperty()
let userProperty = GleapUserProperty()
userProperty.name = "Franz"
userProperty.email = "[email protected]"
userProperty.phone = "+1 (902) 123123"
userProperty.value = 199.95
userProperty.companyId = "Gleap #123"
userProperty.companyName = "Gleap GmbH"
userProperty.plan = "Pro plan"
userProperty.customData = [
"plan": "Pro plan",
"company": "ACME inc."
]
Gleap.identifyUser(with: "129833", andData: userProperty)*/
Gleap.identifyUser(with: "129833", andData: userProperty)

// Testing file attachments.
if let data = "Dies ist ein test.".data(using: String.Encoding.utf8) {
Expand All @@ -70,6 +66,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, GleapDelegate {

}

func notificationCountUpdated(_ count: Int32) {
NSLog("Count updated. %i", count);
}

func widgetClosed() {
NSLog("Closed widget.")
}
Expand Down
2 changes: 1 addition & 1 deletion Gleap.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "Gleap"
s.version = "12.1.0"
s.version = "13.0.0"
s.summary = "In-App Bug Reporting and Testing for Apps. Learn more at https://gleap.io"
s.homepage = "https://gleap.io"
s.license = { :type => 'Commercial', :file => 'LICENSE.md' }
Expand Down
31 changes: 17 additions & 14 deletions Sources/ObjCSources/GleapBanner.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,24 @@ - (void)createWebView {
}

- (void)sendMessageWithData:(NSDictionary *)data {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: data
options: 0
error:&error];
if (!jsonData) {
NSLog(@"[GLEAP_SDK] Error sending message: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
@try {
[self.webView evaluateJavaScript: [NSString stringWithFormat: @"appMessage(%@)", jsonString] completionHandler: nil];
}
@catch(id exception) {}
});
@try {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: data
options: 0
error:&error];
if (!jsonData) {
NSLog(@"[GLEAP_SDK] Error sending message: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
@try {
[self.webView evaluateJavaScript: [NSString stringWithFormat: @"appMessage(%@)", jsonString] completionHandler: nil];
}
@catch(id exception) {}
});
}
}
@catch(id exception) {}
}

- (void)userContentController:(WKUserContentController*)userContentController didReceiveScriptMessage:(WKScriptMessage*)message
Expand Down
1 change: 1 addition & 0 deletions Sources/ObjCSources/GleapCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef enum surveyFormat { SURVEY, SURVEY_FULL } GleapSurveyFormat;
- (void) initialized;
- (void) customActionCalled: (NSString *)customAction;
- (void) configLoaded: (NSDictionary *)config;
- (void) notificationCountUpdated: (int)count;
- (void) widgetOpened;
- (void) widgetClosed;
- (void) registerPushMessageGroup: (NSString *)pushMessageGroup;
Expand Down
32 changes: 32 additions & 0 deletions Sources/ObjCSources/GleapFeedbackButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,38 @@ - (void)updateConstraintsForOrientation {
}
}

- (void)safelyActivateConstraints:(NSArray<NSLayoutConstraint *> *)constraints {
for (NSLayoutConstraint *constraint in constraints) {
if (constraint == nil) {
NSLog(@"Gleap: Attempted to activate a nil constraint.");
continue;
}

if (constraint.firstItem == nil || constraint.secondItem == nil) {
NSLog(@"Gleap: Constraint has nil items: %@", constraint);
continue;
}

UIView *firstView = [constraint.firstItem isKindOfClass:[UIView class]] ? (UIView *)constraint.firstItem : nil;
if (firstView && ![firstView isDescendantOfView: self]) {
NSLog(@"Gleap: First item of constraint is not in the view hierarchy: %@", constraint);
continue;
}

UIView *secondView = [constraint.secondItem isKindOfClass:[UIView class]] ? (UIView *)constraint.secondItem : nil;
if (secondView && ![secondView isDescendantOfView: self]) {
NSLog(@"Gleap: Second item of constraint is not in the view hierarchy: %@", constraint);
continue;
}

@try {
[NSLayoutConstraint activateConstraints:@[constraint]];
} @catch (NSException *exception) {
NSLog(@"Gleap: Exception activating constraint: %@, Exception: %@", constraint, exception);
}
}
}

- (void)setupModernButton {
NSDictionary *config = GleapConfigHelper.sharedInstance.config;
if (config == nil) {
Expand Down
31 changes: 17 additions & 14 deletions Sources/ObjCSources/GleapFrameManagerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,24 @@ - (void)sendPreFillData {
}

- (void)sendMessageWithData:(NSDictionary *)data {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: data
options: 0
error:&error];
if (!jsonData) {
NSLog(@"[GLEAP_SDK] Error sending message: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
@try {
[self.webView evaluateJavaScript: [NSString stringWithFormat: @"sendMessage(%@)", jsonString] completionHandler: nil];
}
@catch(id exception) {}
});
@try {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: data
options: 0
error:&error];
if (!jsonData) {
NSLog(@"[GLEAP_SDK] Error sending message: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
@try {
[self.webView evaluateJavaScript: [NSString stringWithFormat: @"sendMessage(%@)", jsonString] completionHandler: nil];
}
@catch(id exception) {}
});
}
}
@catch(id exception) {}
}

- (void)stopLoading {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ObjCSources/GleapMetaDataHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define SDK_VERSION @"12.1.0"
#define SDK_VERSION @"13.0.0"

NS_ASSUME_NONNULL_BEGIN

Expand Down
3 changes: 3 additions & 0 deletions Sources/ObjCSources/GleapSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, retain, nullable) NSString* email;
@property (nonatomic, retain, nullable) NSString* phone;
@property (nonatomic, retain, nullable) NSString* lang;
@property (nonatomic, retain, nullable) NSString* plan;
@property (nonatomic, retain, nullable) NSString* companyId;
@property (nonatomic, retain, nullable) NSString* companyName;
@property (nonatomic, retain, nullable) NSDictionary* customData;
@property (nonatomic, retain, nullable) NSNumber* value;

Expand Down
3 changes: 3 additions & 0 deletions Sources/ObjCSources/GleapSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ - (NSDictionary *)toDictionary {
@"email": ObjectOrNull(self.email),
@"value": ObjectOrNull(self.value),
@"phone": ObjectOrNull(self.phone),
@"companyId": ObjectOrNull(self.companyId),
@"companyName": ObjectOrNull(self.companyName),
@"plan": ObjectOrNull(self.plan),
@"customData": ObjectOrNull(self.customData)
};
}
Expand Down
26 changes: 25 additions & 1 deletion Sources/ObjCSources/GleapSessionHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ - (void)processOpenIdentityAction {
if (data != nil && data.phone != nil) {
[sessionRequestData setValue: data.phone forKey: @"phone"];
}
if (data != nil && data.plan != nil) {
[sessionRequestData setValue: data.plan forKey: @"plan"];
}
if (data != nil && data.companyId != nil) {
[sessionRequestData setValue: data.companyId forKey: @"companyId"];
}
if (data != nil && data.companyName != nil) {
[sessionRequestData setValue: data.companyName forKey: @"companyName"];
}
if (data != nil && data.value != nil) {
[sessionRequestData setValue: data.value forKey: @"value"];
}
Expand Down Expand Up @@ -290,6 +299,18 @@ - (BOOL)sessionUpgradeWithDataNeeded:(NSDictionary *)newData {
return YES;
}

if ([self sessionDataItemNeedsUpgrade: self.currentSession.plan compareTo: [newData objectForKey: @"plan"]]) {
return YES;
}

if ([self sessionDataItemNeedsUpgrade: self.currentSession.companyName compareTo: [newData objectForKey: @"companyName"]]) {
return YES;
}

if ([self sessionDataItemNeedsUpgrade: self.currentSession.companyId compareTo: [newData objectForKey: @"companyId"]]) {
return YES;
}

if ([self sessionDataItemNeedsUpgrade: self.currentSession.userId compareTo: [newData objectForKey: @"userId"]]) {
return YES;
}
Expand Down Expand Up @@ -331,6 +352,9 @@ - (void)updateLocalSessionWith:(NSDictionary *)data andCompletion:(void (^)(bool
gleapSession.name = [data objectForKey: @"name"];
gleapSession.value = [data objectForKey: @"value"];
gleapSession.lang = [data objectForKey: @"lang"];
gleapSession.companyId = [data objectForKey: @"companyId"];
gleapSession.companyName = [data objectForKey: @"companyName"];
gleapSession.plan = [data objectForKey: @"plan"];
} @catch (id exp) {

}
Expand Down Expand Up @@ -435,7 +459,7 @@ - (BOOL)sessionDataNumberItemNeedsUpgrade:(NSNumber *)data compareTo:(NSNumber *
return YES;
}

return !(data == newData);
return ![data isEqualToNumber: newData];
}

- (NSString *)getSessionName {
Expand Down
6 changes: 5 additions & 1 deletion Sources/ObjCSources/GleapUIOverlayHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ + (void)clear {

if (instance.uiOverlayViewController != nil) {
[instance.uiOverlayViewController setNotifications: instance.notifications];
[instance.uiOverlayViewController updateNotificationCount: 0];
[instance.uiOverlayViewController updateUI];
[GleapUIOverlayHelper updateNotificationCount: 0];
}
});
}
Expand Down Expand Up @@ -75,6 +75,10 @@ + (void)updateNotificationCount:(int)notificationCount {
if ([GleapUIOverlayHelper sharedInstance].uiOverlayViewController != nil) {
[[GleapUIOverlayHelper sharedInstance].uiOverlayViewController updateNotificationCount: notificationCount];
}

if (Gleap.sharedInstance.delegate && [Gleap.sharedInstance.delegate respondsToSelector: @selector(notificationCountUpdated:)]) {
[Gleap.sharedInstance.delegate notificationCountUpdated: notificationCount];
}
});
}

Expand Down
3 changes: 3 additions & 0 deletions Sources/ObjCSources/GleapUserProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, retain) NSString* email;
@property (nonatomic, retain) NSString* phone;
@property (nonatomic, retain) NSNumber* value;
@property (nonatomic, retain) NSString* plan;
@property (nonatomic, retain) NSString* companyName;
@property (nonatomic, retain) NSString* companyId;
@property (nonatomic, retain) NSDictionary* customData;

@end
Expand Down

0 comments on commit 262cc88

Please sign in to comment.