Ta android + ios
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TDAPPPushParams.h
|
||||
// ThinkingSDK
|
||||
//
|
||||
// Created by Charles on 6.5.23.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern id __td_get_userNotificationCenter(void);
|
||||
extern id __td_get_userNotificationCenter_delegate(void);
|
||||
extern NSDictionary * __td_get_userNotificationCenterResponse(id response);
|
||||
extern NSString * __td_get_userNotificationCenterRequestContentTitle(id response);
|
||||
extern NSString * __td_get_userNotificationCenterRequestContentBody(id response);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32c5d3589963cd04d91efdf431b4250e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// TDAPPPushParams.m
|
||||
// ThinkingSDK
|
||||
//
|
||||
// Created by Charles on 6.5.23.
|
||||
//
|
||||
|
||||
#import "TDAPPPushParams.h"
|
||||
|
||||
id __td_get_userNotificationCenter(void) {
|
||||
Class cls = NSClassFromString(@"UNUserNotificationCenter");
|
||||
SEL sel = NSSelectorFromString(@"currentNotificationCenter");
|
||||
if ([cls respondsToSelector:sel]) {
|
||||
id (*getUserNotificationCenterIMP)(id, SEL) = (NSString * (*)(id, SEL))[cls methodForSelector:sel];
|
||||
return getUserNotificationCenterIMP(cls, sel);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
id __td_get_userNotificationCenter_delegate(void) {
|
||||
Class cls = NSClassFromString(@"UNUserNotificationCenter");
|
||||
SEL sel = NSSelectorFromString(@"currentNotificationCenter");
|
||||
SEL delegateSel = NSSelectorFromString(@"delegate");
|
||||
if ([cls respondsToSelector:sel]) {
|
||||
id (*getUserNotificationCenterIMP)(id, SEL) = (id (*)(id, SEL))[cls methodForSelector:sel];
|
||||
id center = getUserNotificationCenterIMP(cls, sel);
|
||||
if (center) {
|
||||
id (*getUserNotificationCenterDelegateIMP)(id, SEL) = (id (*)(id, SEL))[center methodForSelector:delegateSel];
|
||||
id delegate = getUserNotificationCenterDelegateIMP(center, delegateSel);
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSDictionary * __td_get_userNotificationCenterResponse(id response) {
|
||||
|
||||
@try {
|
||||
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
|
||||
return [response valueForKeyPath:@"notification.request.content.userInfo"];
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString * __td_get_userNotificationCenterRequestContentTitle(id response) {
|
||||
|
||||
@try {
|
||||
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
|
||||
return [response valueForKeyPath:@"notification.request.content.title"];
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString * __td_get_userNotificationCenterRequestContentBody(id response) {
|
||||
|
||||
@try {
|
||||
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
|
||||
return [response valueForKeyPath:@"notification.request.content.body"];
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2b06d0e8887f27468ea036fd26d2a42
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDAppDelegateProxyManager : NSObject
|
||||
|
||||
+ (instancetype)defaultManager;
|
||||
|
||||
- (void)proxyNotifications;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4410b4aaaa5a62549a9c6d948a8d1577
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
#import "TDAppDelegateProxyManager.h"
|
||||
#import "TDApplicationDelegateProxy.h"
|
||||
#import "TDNewSwizzle.h"
|
||||
#import "UIApplication+TDPushClick.h"
|
||||
#import "TDMethodHelper.h"
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||
#import "TDUNUserNotificationCenterDelegateProxy.h"
|
||||
#endif
|
||||
|
||||
@implementation TDAppDelegateProxyManager
|
||||
|
||||
+ (instancetype)defaultManager {
|
||||
static dispatch_once_t onceToken;
|
||||
static TDAppDelegateProxyManager *manager = nil;
|
||||
dispatch_once(&onceToken, ^{
|
||||
manager = [[TDAppDelegateProxyManager alloc] init];
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
|
||||
- (void)proxyNotifications NS_EXTENSION_UNAVAILABLE_IOS(""){
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[TDMethodHelper swizzleRespondsToSelector];
|
||||
|
||||
[TDApplicationDelegateProxy resolveOptionalSelectorsForDelegate:[UIApplication sharedApplication].delegate];
|
||||
[TDApplicationDelegateProxy proxyDelegate:[UIApplication sharedApplication].delegate selectors:[NSSet setWithArray:@[@"application:didReceiveLocalNotification:",
|
||||
@"application:didReceiveRemoteNotification:fetchCompletionHandler:",
|
||||
@"application:handleOpenURL:",
|
||||
@"application:openURL:options:",
|
||||
@"application:continueUserActivity:restorationHandler:",
|
||||
@"application:performActionForShortcutItem:completionHandler:"]]];
|
||||
if (@available(iOS 10.0, *)) {
|
||||
if ([UNUserNotificationCenter currentNotificationCenter].delegate) {
|
||||
[TDUNUserNotificationCenterDelegateProxy proxyDelegate:[UNUserNotificationCenter currentNotificationCenter].delegate selectors:[NSSet setWithArray:@[@"userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:"]]];
|
||||
}
|
||||
NSError *error = NULL;
|
||||
[UNUserNotificationCenter td_new_swizzleMethod:@selector(setDelegate:) withMethod:@selector(thinkingdata_setDelegate:) error:&error];
|
||||
if (error) {
|
||||
NSLog(@"proxy notification delegate error: %@", error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abfec29fce672064aab3a832900a873e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
#import "TDDelegateProxy.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDApplicationDelegateProxy : TDDelegateProxy
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca10079e00bccb14a87fcf2f6bd06b08
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
|
||||
#import "TDApplicationDelegateProxy.h"
|
||||
#import "TDClassHelper.h"
|
||||
#import "NSObject+TDDelegateProxy.h"
|
||||
#import "UIApplication+TDPushClick.h"
|
||||
#import <objc/message.h>
|
||||
#import "TDPresetProperties+TDDisProperties.h"
|
||||
#import "TDAppLaunchReason.h"
|
||||
#import "TDCommonUtil.h"
|
||||
|
||||
@implementation TDApplicationDelegateProxy
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
||||
SEL selector = @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:);
|
||||
[TDApplicationDelegateProxy invokeWithTarget:self selector:selector, application, userInfo, completionHandler];
|
||||
[TDApplicationDelegateProxy trackEventWithTarget:self application:application remoteNotification:userInfo];
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||
SEL selector = @selector(application:didReceiveLocalNotification:);
|
||||
[TDApplicationDelegateProxy invokeWithTarget:self selector:selector, application, notification];
|
||||
[TDApplicationDelegateProxy trackEventWithTarget:self application:application localNotification:notification];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
|
||||
SEL selector = @selector(application:continueUserActivity:restorationHandler:);
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": [TDCommonUtil string: userActivity.webpageURL.absoluteString],@"data":@{}};
|
||||
}
|
||||
return [TDApplicationDelegateProxy invokeReturnBOOLWithTarget:self selector:selector arg1:application arg2:userActivity arg3:restorationHandler];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
||||
SEL selector = @selector(application:openURL:options:);
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": [TDCommonUtil string:url.absoluteString],@"data":@{}};
|
||||
}
|
||||
return [TDApplicationDelegateProxy invokeReturnBOOLWithTarget:self selector:selector arg1:app arg2:url arg3:options];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
|
||||
SEL selector = @selector(application:handleOpenURL:);
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": [TDCommonUtil string:url.absoluteString], @"data":@{}};
|
||||
}
|
||||
return [TDApplicationDelegateProxy invokeReturnBOOLWithTarget:self selector:selector arg1:application arg2:url];
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{
|
||||
SEL selector = @selector(application:performActionForShortcutItem:completionHandler:);
|
||||
[TDApplicationDelegateProxy invokeWithTarget:self selector:selector, application, shortcutItem, completionHandler];
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"",@"data": [TDCommonUtil dictionary:shortcutItem.userInfo]};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+ (void)trackEventWithTarget:(NSObject *)target application:(UIApplication *)application remoteNotification:(NSDictionary *)userInfo {
|
||||
|
||||
if (target != application.delegate) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||
NSLog(@"iOS version >= 10.0, callback for %@ was ignored.", @"application:didReceiveRemoteNotification:fetchCompletionHandler:");
|
||||
return;
|
||||
}
|
||||
|
||||
if (application.applicationState != UIApplicationStateInactive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"", @"data": [TDCommonUtil dictionary:userInfo]};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+ (void)trackEventWithTarget:(NSObject *)target application:(UIApplication *)application localNotification:(UILocalNotification *)notification {
|
||||
|
||||
if (target != application.delegate) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL isValidPushClick = NO;
|
||||
if (application.applicationState == UIApplicationStateInactive) {
|
||||
isValidPushClick = YES;
|
||||
}
|
||||
|
||||
if (!isValidPushClick) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
|
||||
properties[@"alertBody"] = notification.alertBody;
|
||||
if (@available(iOS 8.2, *)) {
|
||||
properties[@"alertTitle"] = notification.alertTitle;
|
||||
}
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"", @"data": [TDCommonUtil dictionary:properties]};
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSSet<NSString *> *)optionalSelectors {
|
||||
return [NSSet setWithArray:@[@"application:didReceiveLocalNotification:",
|
||||
@"application:didReceiveRemoteNotification:fetchCompletionHandler:",
|
||||
@"application:handleOpenURL:",
|
||||
@"application:openURL:options:",
|
||||
@"application:continueUserActivity:restorationHandler:",
|
||||
@"application:performActionForShortcutItem:completionHandler:"]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fcf40a52d81b34458cb1a00a973d114
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#import "TDDelegateProxy.h"
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDUNUserNotificationCenterDelegateProxy : TDDelegateProxy
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 805747b0abfc919409c3f41976e0da46
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
#import "TDUNUserNotificationCenterDelegateProxy.h"
|
||||
#import "TDClassHelper.h"
|
||||
#import "NSObject+TDDelegateProxy.h"
|
||||
#import <objc/message.h>
|
||||
#import "TDAPPPushParams.h"
|
||||
#import "TDPresetProperties+TDDisProperties.h"
|
||||
#import "TDAppLaunchReason.h"
|
||||
#import "TDCommonUtil.h"
|
||||
|
||||
@implementation TDUNUserNotificationCenterDelegateProxy
|
||||
|
||||
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){
|
||||
SEL selector = @selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:);
|
||||
[TDUNUserNotificationCenterDelegateProxy invokeWithTarget:self selector:selector, center, response, completionHandler];
|
||||
[TDUNUserNotificationCenterDelegateProxy trackEventWithTarget:self notificationCenter:center notificationResponse:response];
|
||||
}
|
||||
|
||||
+ (void)trackEventWithTarget:(NSObject *)target notificationCenter:(UNUserNotificationCenter *)center notificationResponse:(UNNotificationResponse *)response API_AVAILABLE(ios(10.0)){
|
||||
|
||||
if (target != center.delegate) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (![TDPresetProperties disableStartReason]) {
|
||||
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
|
||||
NSDictionary *userInfo = __td_get_userNotificationCenterResponse(response);
|
||||
if (userInfo) {
|
||||
[properties addEntriesFromDictionary:userInfo];
|
||||
}
|
||||
properties[@"title"] = __td_get_userNotificationCenterRequestContentTitle(response);
|
||||
properties[@"body"] = __td_get_userNotificationCenterRequestContentBody(response);
|
||||
|
||||
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
|
||||
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"", @"data": [TDCommonUtil dictionary:properties]};
|
||||
}
|
||||
|
||||
if (![TDPresetProperties disableOpsReceiptProperties]) {
|
||||
@try {
|
||||
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
|
||||
NSDictionary *userInfo = [response valueForKeyPath:@"notification.request.content.userInfo"];
|
||||
[TDAppLaunchReason td_ops_push_click:userInfo];
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+ (NSSet<NSString *> *)optionalSelectors {
|
||||
return [NSSet setWithArray:@[@"userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:"]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e1d9a52ad6d1bb448047d9511f65af6
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIApplication (TDPushClick)
|
||||
|
||||
- (void)thinkingdata_setDelegate:(id <UIApplicationDelegate>)delegate;
|
||||
@property (nonatomic, copy, nullable) NSDictionary *thinkingdata_launchOptions;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1079c5db6551594781ca867e7f6839e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#import "UIApplication+TDPushClick.h"
|
||||
#import "TDApplicationDelegateProxy.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
static void *const kSALaunchOptions = (void *)&kSALaunchOptions;
|
||||
|
||||
@implementation UIApplication (TDPushClick)
|
||||
|
||||
- (void)thinkingdata_setDelegate:(id<UIApplicationDelegate>)delegate {
|
||||
[TDApplicationDelegateProxy resolveOptionalSelectorsForDelegate:delegate];
|
||||
|
||||
[self thinkingdata_setDelegate:delegate];
|
||||
|
||||
if (!self.delegate) {
|
||||
return;
|
||||
}
|
||||
[TDApplicationDelegateProxy proxyDelegate:self.delegate selectors:[NSSet setWithArray:@[@"application:didReceiveLocalNotification:", @"application:didReceiveRemoteNotification:fetchCompletionHandler:"]]];
|
||||
}
|
||||
|
||||
- (NSDictionary *)thinkingdata_launchOptions {
|
||||
return objc_getAssociatedObject(self, kSALaunchOptions);
|
||||
}
|
||||
|
||||
- (void)setThinkingdata_launchOptions:(NSDictionary *)thinkingdata_launchOptions {
|
||||
objc_setAssociatedObject(self, kSALaunchOptions, thinkingdata_launchOptions, OBJC_ASSOCIATION_COPY);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfc60789a07708e4da5c6c0d000e37ee
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UNUserNotificationCenter (TDPushClick)
|
||||
|
||||
- (void)thinkingdata_setDelegate:(id <UNUserNotificationCenterDelegate>)delegate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 649e54e5cf5169f46806d54fb005049f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
#import "UNUserNotificationCenter+TDPushClick.h"
|
||||
#import "TDUNUserNotificationCenterDelegateProxy.h"
|
||||
|
||||
@implementation UNUserNotificationCenter (TDPushClick)
|
||||
|
||||
- (void)thinkingdata_setDelegate:(id<UNUserNotificationCenterDelegate>)delegate {
|
||||
|
||||
[TDUNUserNotificationCenterDelegateProxy resolveOptionalSelectorsForDelegate:delegate];
|
||||
|
||||
[self thinkingdata_setDelegate:delegate];
|
||||
if (!self.delegate) {
|
||||
return;
|
||||
}
|
||||
[TDUNUserNotificationCenterDelegateProxy proxyDelegate:self.delegate selectors:[NSSet setWithArray:@[@"userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:"]]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 450f884bacd370f45b28a1869861f2d8
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user