Skip to content

Commit

Permalink
Merge pull request #543 from qonversion/tech/sc-35135/deprecatePushToken
Browse files Browse the repository at this point in the history
The setNotificationsToken and handleNotification methods were marked as deprecated.
  • Loading branch information
SpertsyanKM authored Sep 30, 2024
2 parents df528fe + 95b3dbf commit 1539000
Show file tree
Hide file tree
Showing 24 changed files with 8 additions and 222 deletions.
20 changes: 0 additions & 20 deletions IntegrationTests/QNAPIClientIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -529,26 +529,6 @@ - (void)testIdentifyError {
[self waitForExpectationsWithTimeout:self.kRequestTimeout handler:nil];
}

- (void)testSendPushToken {
// given
XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Send push token call"];
NSString *uid = [NSString stringWithFormat:@"%@%@", self.kUidPrefix, @"_sendPushToken"];
QNAPIClient *client = [self getClient:uid];

// when
[client launchRequest:^(NSDictionary * _Nullable initRes, NSError * _Nullable createUserError) {
XCTAssertNil(createUserError);

[client sendPushToken:^(BOOL success) {
XCTAssertFalse(success); // no push token on emulator
[completionExpectation fulfill];
}];
}];

// then
[self waitForExpectationsWithTimeout:self.kRequestTimeout handler:nil];
}

- (void)testScreens {
// given
XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Screens call"];
Expand Down
20 changes: 0 additions & 20 deletions IntegrationTests/QNOutagerIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,26 +329,6 @@ - (void)testIdentify {
[self waitForExpectationsWithTimeout:self.kRequestTimeout handler:nil];
}

- (void)testSendPushToken {
// given
XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Send push token call"];
NSString *uid = [NSString stringWithFormat:@"%@%@", self.kUidPrefix, @"_sendPushToken"];
QNAPIClient *client = [self getClient:uid];

// when
[client launchRequest:^(NSDictionary * _Nullable initRes, NSError * _Nullable createUserError) {
XCTAssertNil(createUserError);

[client sendPushToken:^(BOOL success) {
XCTAssertFalse(success);
[completionExpectation fulfill];
}];
}];

// then
[self waitForExpectationsWithTimeout:self.kRequestTimeout handler:nil];
}

- (void)testScreens {
// given
XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Screens call"];
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 578415250db59f137d92c9b1ce32646ae18974ba

COCOAPODS: 1.15.2
COCOAPODS: 1.13.0
20 changes: 2 additions & 18 deletions Qonversion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
701922762B10AB3300724926 /* QONSubscriptionPeriod+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = 701922752B10AB3300724926 /* QONSubscriptionPeriod+Protected.h */; };
701BAC102C524626009B16FB /* QONPurchaseOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 701BAC0F2C524626009B16FB /* QONPurchaseOptions.m */; };
701BAC112C524626009B16FB /* QONPurchaseOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 701BAC0E2C524626009B16FB /* QONPurchaseOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
702394912923EBF3003126D5 /* QONNotificationsService.h in Headers */ = {isa = PBXBuildFile; fileRef = 7023948F2923EBF3003126D5 /* QONNotificationsService.h */; };
702394922923EBF3003126D5 /* QONNotificationsService.m in Sources */ = {isa = PBXBuildFile; fileRef = 702394902923EBF3003126D5 /* QONNotificationsService.m */; };
70283DF729F66FAC00D138BC /* PurchasesMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70283DF629F66FAC00D138BC /* PurchasesMapper.swift */; };
702BF8B629531A68000B6C3E /* QONScreenCustomizationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
702DBDEC2A3216C900D590D0 /* QONExperiment+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = 702DBDEB2A3216C900D590D0 /* QONExperiment+Protected.h */; };
Expand Down Expand Up @@ -393,8 +391,6 @@
701922752B10AB3300724926 /* QONSubscriptionPeriod+Protected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QONSubscriptionPeriod+Protected.h"; sourceTree = "<group>"; };
701BAC0E2C524626009B16FB /* QONPurchaseOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONPurchaseOptions.h; sourceTree = "<group>"; };
701BAC0F2C524626009B16FB /* QONPurchaseOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONPurchaseOptions.m; sourceTree = "<group>"; };
7023948F2923EBF3003126D5 /* QONNotificationsService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONNotificationsService.h; sourceTree = "<group>"; };
702394902923EBF3003126D5 /* QONNotificationsService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONNotificationsService.m; sourceTree = "<group>"; };
70283DF629F66FAC00D138BC /* PurchasesMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PurchasesMapper.swift; sourceTree = "<group>"; };
702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONScreenCustomizationDelegate.h; sourceTree = "<group>"; };
702DBDEB2A3216C900D590D0 /* QONExperiment+Protected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QONExperiment+Protected.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -906,15 +902,6 @@
path = "NSError+Sugare";
sourceTree = "<group>";
};
7023948E2923EBE8003126D5 /* QONNotificationsService */ = {
isa = PBXGroup;
children = (
7023948F2923EBF3003126D5 /* QONNotificationsService.h */,
702394902923EBF3003126D5 /* QONNotificationsService.m */,
);
path = QONNotificationsService;
sourceTree = "<group>";
};
70283DF529F66FAC00D138BC /* Swift */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1235,7 +1222,6 @@
8957320126DD03A3009507A6 /* Services */ = {
isa = PBXGroup;
children = (
7023948E2923EBE8003126D5 /* QONNotificationsService */,
8957320226DD03A3009507A6 /* QONAutomationsService */,
8957320526DD03A3009507A6 /* QONAutomationsScreenProcessor */,
);
Expand Down Expand Up @@ -1737,7 +1723,6 @@
895732F326DD03A3009507A6 /* QNUserPropertiesManager.h in Headers */,
70F07B1B28AD085600A45D41 /* QONEntitlementsCacheLifetime.h in Headers */,
707734F42A9F607700CFF742 /* QONRemoteConfigurationSource.h in Headers */,
702394912923EBF3003126D5 /* QONNotificationsService.h in Headers */,
895732F126DD03A3009507A6 /* QNMapper.h in Headers */,
7097C6BE2A38BFC800565DE4 /* QONRemoteConfig+Protected.h in Headers */,
895732DF26DD03A3009507A6 /* QONUser+Protected.h in Headers */,
Expand Down Expand Up @@ -2135,7 +2120,6 @@
895732B326DD03A3009507A6 /* QONAutomationsViewController.m in Sources */,
895732EC26DD03A3009507A6 /* QNUserInfoMapper.m in Sources */,
895732B526DD03A3009507A6 /* QONAutomationsService.m in Sources */,
702394922923EBF3003126D5 /* QONNotificationsService.m in Sources */,
8957328A26DD03A3009507A6 /* QONActionResult.m in Sources */,
70283DF729F66FAC00D138BC /* PurchasesMapper.swift in Sources */,
701BAC102C524626009B16FB /* QONPurchaseOptions.m in Sources */,
Expand Down Expand Up @@ -2578,7 +2562,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = MTVL2X9L7N;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 5ZBNSPDUJ2;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 1.0;
Expand All @@ -2599,7 +2583,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = MTVL2X9L7N;
DEVELOPMENT_TEAM = 5ZBNSPDUJ2;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#if TARGET_OS_IOS

@class QONAutomationsViewController, QONAutomationsService, QONAutomationsActionsHandler, QONAutomationsScreen, QONAutomationsEventsMapper, QONNotificationsService;
@class QONAutomationsViewController, QONAutomationsService, QONAutomationsActionsHandler, QONAutomationsScreen, QONAutomationsEventsMapper;
@protocol QONAutomationsViewControllerDelegate;

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -21,7 +21,6 @@ NS_ASSUME_NONNULL_BEGIN
- (QONAutomationsService *)automationsService;
- (QONAutomationsActionsHandler *)actionsHandler;
- (QONAutomationsEventsMapper *)eventsMapper;
- (QONNotificationsService *)notificationsService;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import "QONAutomationsScreen.h"
#import "QONAutomationsScreenProcessor.h"
#import "QONAutomationsEventsMapper.h"
#import "QONNotificationsService.h"

@implementation QONAutomationsFlowAssembly

Expand All @@ -44,13 +43,6 @@ - (QONAutomationsService *)automationsService {
return automationsService;
}

- (QONNotificationsService *)notificationsService {
QONNotificationsService *notificationsService = [QONNotificationsService new];
notificationsService.apiClient = [QNAPIClient shared];

return notificationsService;
}

- (QONAutomationsMapper *)screensMapper {
return [QONAutomationsMapper new];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showAutomationWithID:(NSString *)automationID completion:(nullable QONShowScreenCompletionHandler)completion;
- (BOOL)handlePushNotification:(NSDictionary *)userInfo;
- (void)showAutomationIfExists;
- (void)sendPushToken:(NSData *)pushTokenData;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#import "QONAutomationsEventsMapper.h"
#import "QNInternalConstants.h"
#import "QNDevice.h"
#import "QONNotificationsService.h"
#import "QONScreenCustomizationDelegate.h"
#import "QONAutomationsNavigationController.h"

Expand All @@ -35,7 +34,6 @@ @interface QONAutomationsFlowCoordinator() <QONAutomationsViewControllerDelegate
@property (nonatomic, strong) QONAutomationsFlowAssembly *assembly;
@property (nonatomic, strong) QONAutomationsService *automationsService;
@property (nonatomic, strong) QONAutomationsEventsMapper *eventsMapper;
@property (nonatomic, strong) QONNotificationsService *notificationsService;
@property (nonatomic, assign) BOOL isSDKLaunched;

@end
Expand All @@ -59,16 +57,13 @@ - (instancetype)init {
_assembly = [QONAutomationsFlowAssembly new];
_automationsService = [_assembly automationsService];
_eventsMapper = [_assembly eventsMapper];
_notificationsService = [_assembly notificationsService];
}

return self;
}

- (void)didFinishLaunch {
self.isSDKLaunched = YES;

[self processPushTokenRequest];
}

- (void)setAutomationsDelegate:(id<QONAutomationsDelegate>)automationsDelegate {
Expand Down Expand Up @@ -118,33 +113,6 @@ - (void)showAutomationIfExists {
}];
}

- (void)sendPushToken:(NSData *)pushTokenData {
NSString *tokenString = [QNUtils convertHexData:pushTokenData];
NSString *oldToken = [QNDevice current].pushNotificationsToken;
if ([tokenString isEqualToString:oldToken] || tokenString.length == 0) {
return;
}

[[QNDevice current] setPushNotificationsToken:tokenString];
[[QNDevice current] setPushTokenProcessed:NO];

if (!self.isSDKLaunched) {
return;
}

[self processPushTokenRequest];
}

- (void)processPushTokenRequest {
NSString *pushToken = [[QNDevice current] pushNotificationsToken];
BOOL isPushTokenProcessed = [[QNDevice current] isPushTokenProcessed];
if (!pushToken || isPushTokenProcessed) {
return;
}

[self.notificationsService sendPushToken];
}

- (void)showAutomationWithID:(NSString *)automationID completion:(nullable QONShowScreenCompletionHandler)completion {
__block __weak QONAutomationsFlowCoordinator *weakSelf = self;
[self.automationsService automationWithID:automationID completion:^(QONAutomationsScreen *screen, NSError * _Nullable error) {
Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/Qonversion/Public/QONAutomations.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ NS_SWIFT_NAME(setScreenCustomizationDelegate(_:));
Set push token to Qonversion to enable Qonversion push notifications
@param token - token data
*/
- (void)setNotificationsToken:(nonnull NSData *)token API_AVAILABLE(ios(9.0));
- (void)setNotificationsToken:(nonnull NSData *)token API_AVAILABLE(ios(9.0)) DEPRECATED_MSG_ATTRIBUTE("Consider removing this method calls as they aren't needed anymore");

/**
Returns true when a push notification was received from Qonversion.
Otherwise returns false, so you need to handle a notification yourself
@param userInfo - notification user info
*/
- (BOOL)handleNotification:(nonnull NSDictionary *)userInfo API_AVAILABLE(ios(9.0));
- (BOOL)handleNotification:(nonnull NSDictionary *)userInfo API_AVAILABLE(ios(9.0)) DEPRECATED_MSG_ATTRIBUTE("Consider removing this method calls. Qonversion is not working with push notifications anymore");

/**
Get parsed custom payload, which you added to the notification in the dashboard
Expand Down
4 changes: 1 addition & 3 deletions Sources/Qonversion/Public/QONAutomations.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ - (void)showScreenWithID:(nonnull NSString *)screenID completion:(nullable QONSh
[[QONAutomationsFlowCoordinator sharedInstance] showAutomationWithID:screenID completion:completion];
}

- (void)setNotificationsToken:(nonnull NSData *)token {
[[QONAutomationsFlowCoordinator sharedInstance] sendPushToken:token];
}
- (void)setNotificationsToken:(nonnull NSData *)token {}

- (BOOL)handleNotification:(nonnull NSDictionary *)userInfo {
return [[QONAutomationsFlowCoordinator sharedInstance] handlePushNotification:userInfo];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

extern NSString *const kAPIBase;
extern NSString *const kInitEndpoint;
extern NSString *const kSendPushTokenEndpoint;
extern NSString *const kPurchaseEndpoint;
extern NSString *const kGetPromoOfferDetailsEndpoint;
extern NSString *const kProductsEndpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
NSString * const kSdkLogsBaseURL = @"https://sdk-logs.qonversion.io/";

NSString * const kInitEndpoint = @"v1/user/init";
NSString * const kSendPushTokenEndpoint = @"v1/user/push-token";
NSString * const kPurchaseEndpoint = @"v1/user/purchase";
// TODO: Update endpoint
NSString * const kGetPromoOfferDetailsEndpoint = @"update_promo_offer_endpoint_here";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ typedef NS_ENUM(NSInteger, QONRequestType) {
- (void)setBaseURL:(NSString *)url;
- (void)setSDKVersion:(NSString *)version;
- (NSURLRequest *)makeInitRequestWith:(NSDictionary *)parameters;
- (NSURLRequest *)makeSendPushTokenRequestWith:(NSDictionary *)parameters;
- (NSURLRequest *)makeUserInfoRequestWithID:(NSString *)userID apiKey:(NSString *)apiKey;
- (NSURLRequest *)makeSendPropertiesRequestForUserId:(NSString *)userId parameters:(NSArray *)parameters;
- (NSURLRequest *)makeGetPropertiesRequestForUserId:(NSString *)userId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ - (void)setBaseURL:(NSString *)url {
_baseURL = url;
}

- (NSURLRequest *)makeSendPushTokenRequestWith:(NSDictionary *)parameters {
return [self makeRequestWithDictBody:parameters baseURL:self.baseURL endpoint:kSendPushTokenEndpoint type:QONRequestTypePost];
}

- (NSURLRequest *)makeInitRequestWith:(NSDictionary *)parameters {
return [self makeRequestWithDictBody:parameters baseURL:self.baseURL endpoint:kInitEndpoint type:QONRequestTypePost];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ NS_ASSUME_NONNULL_BEGIN
purchaseOptions:(nullable QONPurchaseOptions *)purchaseOptions;

- (NSDictionary *)introTrialEligibilityDataForProducts:(NSArray<QONProduct *> *)products;
- (NSDictionary *)pushTokenData;

- (NSDictionary *)attributionDataWithDict:(NSDictionary *)data fromProvider:(QONAttributionProvider)provider;
- (NSDictionary *)purchaseInfo:(QONStoreKit2PurchaseModel *)purchaseInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ - (NSDictionary *)mainData {
return QNUserInfo.overallData;
}

- (NSDictionary *)pushTokenData {
NSMutableDictionary *data = [NSMutableDictionary new];
data[@"push_token"] = [[QNDevice current] pushNotificationsToken];
data[@"device_id"] = [[QNDevice current] vendorID];

return [data copy];
}

- (NSDictionary *)purchaseData:(SKProduct *)product
transaction:(SKPaymentTransaction *)transaction
receipt:(nullable NSString *)receipt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setSDKVersion:(NSString *)version;
- (void)setBaseURL:(NSString *)url;
- (void)launchRequest:(QNAPIClientDictCompletionHandler)completion;
- (void)sendPushToken:(void (^)(BOOL success))completion;

- (NSURLRequest *)purchaseRequestWith:(SKProduct *)product
transaction:(SKPaymentTransaction *)transaction
Expand Down
Loading

0 comments on commit 1539000

Please sign in to comment.