Skip to content

Commit

Permalink
chagne to campaign name
Browse files Browse the repository at this point in the history
  • Loading branch information
KennyHuRadar committed Dec 5, 2024
1 parent d843c1e commit 6519ac2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions RadarSDK/Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ + (void)logConversionWithNotification:(UNNotificationRequest *)request
if (deliveredAfter) {
[metadata setObject:deliveredAfter forKey:@"deliveredAfter"];
}
if (result[@"campaignId"]) {
[metadata setValue:result[@"campaignId"] forKey:@"campaignId"];
if (result[@"campaignName"]) {
[metadata setValue:result[@"campaignName"] forKey:@"campaignName"];
}
}

Expand Down
6 changes: 3 additions & 3 deletions RadarSDK/RadarLocationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ - (void)replaceSyncedGeofences:(NSArray<RadarGeofence *> *)geofences {
NSString *notificationTitle = [geofence.metadata objectForKey:@"radar:notificationTitle"];
NSString *notificationSubtitle = [geofence.metadata objectForKey:@"radar:notificationSubtitle"];
NSString *notificationURL = [geofence.metadata objectForKey:@"radar:notificationURL"];
NSString *campaignId = [geofence.metadata objectForKey:@"radar:campaignId"];
NSString *campaignName = [geofence.metadata objectForKey:@"radar:campaignName"];
if (notificationText) {
UNMutableNotificationContent *content = [UNMutableNotificationContent new];
if (notificationTitle) {
Expand Down Expand Up @@ -589,8 +589,8 @@ - (void)replaceSyncedGeofences:(NSArray<RadarGeofence *> *)geofences {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelDebug message:@"Notification does not repeat"];
}

if (campaignId) {
identifier = [RadarNotificationHelper getNotificationIdentifier:geofenceId campaignId:campaignId];
if (campaignName) {
identifier = [RadarNotificationHelper getNotificationIdentifier:geofenceId campaignName:campaignName];
}

UNLocationNotificationTrigger *trigger = [UNLocationNotificationTrigger triggerWithRegion:region repeats:repeats];
Expand Down
4 changes: 2 additions & 2 deletions RadarSDK/RadarNotificationHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ typedef void (^NotificationPermissionCheckCompletion)(BOOL granted);

+ (void)openURLFromNotification:(UNNotification *)notification;

+ (NSString *)getNotificationIdentifier:(NSString *)geofenceId campaignId:(NSString *)campaignId;
+ (NSString *)getNotificationIdentifier:(NSString *)geofenceId campaignName:(NSString *)campaignName;

+ (NSDictionary<NSString *, NSString *> *)extractMetadataFromNotificationIdentifier:(NSString *)identifier;

// + (NSString *)getCampaignIdFromNotificationIdentifier:(NSString *)notificationIdentifier;
// + (NSString *)getcampaignNameFromNotificationIdentifier:(NSString *)notificationIdentifier;

@end

Expand Down
18 changes: 9 additions & 9 deletions RadarSDK/RadarNotificationHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ + (void)checkNotificationPermissionsWithCompletionHandler:(NotificationPermissio
}
}

+ (NSString *)getNotificationIdentifier:(NSString *)geofenceId campaignId:(NSString *)campaignId {
+ (NSString *)getNotificationIdentifier:(NSString *)geofenceId campaignName:(NSString *)campaignName {
NSString *identifier = [NSString stringWithFormat:@"%@%@", kSyncGeofenceIdentifierPrefix, geofenceId];
NSDate *now = [NSDate new];
NSTimeInterval lastSyncInterval = [now timeIntervalSince1970];
identifier = [identifier stringByAppendingString:[NSString stringWithFormat:@"_%f", lastSyncInterval]];
if (campaignId) {
if (campaignName) {
identifier = [identifier stringByAppendingString:@"_"];
identifier = [identifier stringByAppendingString:campaignId];
identifier = [identifier stringByAppendingString:campaignName];
}
return identifier;
}
Expand All @@ -238,8 +238,8 @@ + (NSString *)getNotificationIdentifier:(NSString *)geofenceId campaignId:(NSStr
NSString *geofenceId = components[2];
NSString *registeredAt = components[3];
if (components.count == 5) {
NSString *campaignId = components[4];
result = @{@"geofenceId": geofenceId, @"registeredAt": registeredAt, @"campaignId":campaignId};
NSString *campaignName = components[4];
result = @{@"geofenceId": geofenceId, @"registeredAt": registeredAt, @"campaignName":campaignName};
} else {

result = @{@"geofenceId": geofenceId, @"registeredAt": registeredAt};
Expand All @@ -249,15 +249,15 @@ + (NSString *)getNotificationIdentifier:(NSString *)geofenceId campaignId:(NSStr
return result;
}

+ (NSString *)getCampaignIdFromNotificationIdentifier:(NSString *)notificationIdentifier {
NSString *campaignId = nil;
+ (NSString *)getcampaignNameFromNotificationIdentifier:(NSString *)notificationIdentifier {
NSString *campaignName = nil;
if ([notificationIdentifier hasPrefix:kSyncGeofenceIdentifierPrefix]) {
NSArray *components = [notificationIdentifier componentsSeparatedByString:@"_"];
if (components.count == 4) {
campaignId = components[3];
campaignName = components[3];
}
}
return campaignId;
return campaignName;
}

@end

0 comments on commit 6519ac2

Please sign in to comment.