change
This commit is contained in:
parent
1c20bd5a97
commit
0289958a33
28
ios/AppMetrica+AppDelegate.h
Normal file
28
ios/AppMetrica+AppDelegate.h
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// AppMetrica+Delegate.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Andrey Bondarenko on 16.02.2021.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
#ifndef AppMetrica_Delegate_h
|
||||
#define AppMetrica_Delegate_h
|
||||
|
||||
|
||||
#endif /* AppMetrica_Delegate_h */
|
||||
|
||||
@interface AppMetricaDelegateApp : NSObject <UIApplicationDelegate>
|
||||
|
||||
+ (_Nonnull instancetype)sharedInstance;
|
||||
|
||||
- (void)observe;
|
||||
|
||||
|
||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
|
||||
|
||||
|
||||
@end
|
43
ios/AppMetrica+AppDelegate.m
Normal file
43
ios/AppMetrica+AppDelegate.m
Normal file
@ -0,0 +1,43 @@
|
||||
//
|
||||
// AppMetrica+Delegate.m
|
||||
// react-native-appmetrica-next
|
||||
//
|
||||
// Created by Andrey Bondarenko on 16.02.2021.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "AppMetrica+AppDelegate.h"
|
||||
|
||||
|
||||
@implementation AppMetricaDelegateApp
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static dispatch_once_t once;
|
||||
__strong static AppMetricaDelegateApp *sharedInstance;
|
||||
dispatch_once(&once, ^{
|
||||
sharedInstance = [[AppMetricaDelegateApp alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
|
||||
- (void)observe {
|
||||
static dispatch_once_t once;
|
||||
__weak AppMetricaDelegateApp *weakSelf = self;
|
||||
dispatch_once(&once, ^{
|
||||
AppMetricaDelegateApp *strongSelf = weakSelf;
|
||||
|
||||
|
||||
SEL didReceiveRemoteNotificationWithCompletionSEL =
|
||||
NSSelectorFromString(@"application:didReceiveRemoteNotification:fetchCompletionHandler:");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// called when `registerForRemoteNotifications` completes successfully
|
||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
NSLog(@"deviceToken 41");
|
||||
}
|
||||
|
||||
@end
|
@ -5,9 +5,11 @@
|
||||
* You may obtain a copy of the License at
|
||||
* https://yandex.com/legal/appmetrica_sdk_agreement/
|
||||
*/
|
||||
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
@interface AppMetrica : NSObject <RCTBridgeModule>
|
||||
+ (NSDictionary *)addCustomPropsToUserProps:(NSDictionary *_Nullable)userProps withLaunchOptions:(NSDictionary *_Nullable)launchOptions;
|
||||
|
||||
@end
|
||||
|
@ -6,9 +6,13 @@
|
||||
* https://yandex.com/legal/appmetrica_sdk_agreement/
|
||||
*/
|
||||
|
||||
#import <React/RCTConvert.h>
|
||||
#import "AppMetrica.h"
|
||||
#import <Firebase/Firebase.h>
|
||||
#import "AppMetricaUtils.h"
|
||||
#import <YandexMobileMetricaPush/YMPYandexMetricaPush.h>
|
||||
#import "AppMetrica+AppDelegate.h"
|
||||
|
||||
|
||||
static NSString *const kYMMReactNativeExceptionName = @"ReactNativeException";
|
||||
|
||||
@ -16,7 +20,36 @@ static NSString *const kYMMReactNativeExceptionName = @"ReactNativeException";
|
||||
|
||||
@synthesize methodQueue = _methodQueue;
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (dispatch_queue_t)methodQueue {
|
||||
return dispatch_get_main_queue();
|
||||
}
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup {
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
+ (NSDictionary *)addCustomPropsToUserProps:(NSDictionary *_Nullable)userProps withLaunchOptions:(NSDictionary *_Nullable)launchOptions {
|
||||
NSMutableDictionary *appProperties = userProps != nil ? [userProps mutableCopy] : [NSMutableDictionary dictionary];
|
||||
appProperties[@"isHeadless"] = @([RCTConvert BOOL:@(NO)]);
|
||||
|
||||
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
|
||||
appProperties[@"isHeadless"] = @([RCTConvert BOOL:@(YES)]);
|
||||
}
|
||||
}
|
||||
|
||||
return [NSDictionary dictionaryWithDictionary:appProperties];
|
||||
}
|
||||
|
||||
|
||||
RCT_EXPORT_METHOD(activate:(NSDictionary *)configDict)
|
||||
{
|
||||
@ -30,9 +63,36 @@ RCT_EXPORT_METHOD(reportUserProfile:(NSDictionary *)configDict)
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
//
|
||||
// NSLog(@"deviceToken");
|
||||
// If the library AppMetrica the SDK was not initialized before this step,
|
||||
// the method call will result in emergency stop applications.
|
||||
// #ifdef DEBUG
|
||||
// YMPYandexMetricaPushEnvironment pushEnvironment = YMPYandexMetricaPushEnvironmentDevelopment;
|
||||
// #else
|
||||
// YMPYandexMetricaPushEnvironment pushEnvironment = YMPYandexMetricaPushEnvironmentProduction;
|
||||
// #endif
|
||||
// [YMPYandexMetricaPush setDeviceTokenFromData:deviceToken pushEnvironment:pushEnvironment];
|
||||
//}
|
||||
|
||||
RCT_EXPORT_METHOD(initPush:(NSData *)deviceToken)
|
||||
{
|
||||
[YMPYandexMetricaPush setDeviceTokenFromData:deviceToken];
|
||||
// [YMPYandexMetricaPush setDeviceTokenFromData:deviceToken];
|
||||
// NSLog(@"deviceToken 7", [FIRMessaging messaging].APNSToken);
|
||||
// NSLog([FIRMessaging messaging].APNSToken);
|
||||
|
||||
#ifdef DEBUG
|
||||
YMPYandexMetricaPushEnvironment pushEnvironment = YMPYandexMetricaPushEnvironmentDevelopment;
|
||||
#else
|
||||
YMPYandexMetricaPushEnvironment pushEnvironment = YMPYandexMetricaPushEnvironmentProduction;
|
||||
#endif
|
||||
[YMPYandexMetricaPush setDeviceTokenFromData:[FIRMessaging messaging].APNSToken pushEnvironment:pushEnvironment];
|
||||
|
||||
|
||||
// RNFBMessagingAppDelegate
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getLibraryApiLevel)
|
||||
@ -55,6 +115,9 @@ RCT_EXPORT_METHOD(reportAppOpen:(NSString *)deeplink)
|
||||
[YMMYandexMetrica handleOpenURL:[NSURL URLWithString:deeplink]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RCT_EXPORT_METHOD(reportError:(NSString *)message) {
|
||||
NSException *exception = [[NSException alloc] initWithName:message reason:nil userInfo:nil];
|
||||
[YMMYandexMetrica reportError:message exception:exception onFailure:NULL];
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "react-native-appmetrica-next",
|
||||
"title": "Yandex AppMetrica React Native Plugin && AppMetricaPushSDK (fireBase CloudMessage)",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.13",
|
||||
"description": "React Native plugin for AppMetrica analytics tool",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user