update files iOS

This commit is contained in:
Andrey Bondarenko
2021-01-21 18:23:32 +10:00
parent 8a0af3388d
commit 79c045577c
5 changed files with 45 additions and 3 deletions

View File

@@ -23,7 +23,15 @@ RCT_EXPORT_METHOD(activate:(NSDictionary *)configDict)
[YMMYandexMetrica activateWithConfiguration:[AppMetricaUtils configurationForDictionary:configDict]];
}
RCT_EXPORT_METHOD(initPush:(NSString *)deviceToken)
RCT_EXPORT_METHOD(reportUserProfile:(NSDictionary *)configDict)
{
// [YMPYandexMetrica reportUserProfile:[AppMetricaUtils configurationForUserProfile:configDict]];
[YMMYandexMetrica reportUserProfile:[AppMetricaUtils configurationForUserProfile:configDict] onFailure:^(NSError *error) {
NSLog(@"Error: %@", error);
}];
}
RCT_EXPORT_METHOD(initPush:(NSData *)deviceToken)
{
[YMPYandexMetricaPush setDeviceTokenFromData:deviceToken];
}

View File

@@ -52,6 +52,38 @@
return configuration;
}
+ (YMMMutableUserProfile *)configurationForUserProfile:(NSDictionary *)configDict
{
YMMMutableUserProfile *profile = [[YMMMutableUserProfile alloc] init];
id<YMMCustomCounterAttribute> timeLeftAttribute = [YMMProfileAttribute customCounter:@"time_left"];
[profile apply:[timeLeftAttribute withDelta:-4.42]];
if (configDict[@"name"] != nil) {
id<YMMNameAttribute> nameAttribute = [YMMProfileAttribute name];
[profile apply:[nameAttribute withValue:configDict[@"name"]]];
}
if (configDict[@"floor"] != nil && [configDict[@"floor"] isEqualToString:@"male"]) {
id<YMMGenderAttribute> genderAttribute = [YMMProfileAttribute gender];
[profile apply:[genderAttribute withValue:YMMGenderTypeMale]];
}
if (configDict[@"floor"] != nil && [configDict[@"floor"] isEqualToString:@"female"]) {
id<YMMGenderAttribute> genderAttribute = [YMMProfileAttribute gender];
[profile apply:[genderAttribute withValue:YMMGenderTypeFemale]];
}
if (configDict[@"age"] != nil) {
id<YMMBirthDateAttribute> birthDateAttribute = [YMMProfileAttribute birthDate];
[profile apply:[birthDateAttribute withAge:[configDict[@"age"] unsignedIntegerValue]]];
}
if (configDict[@"isNotification"] != nil) {
id<YMMNotificationsEnabledAttribute> isNotificationAttribute = [YMMProfileAttribute notificationsEnabled];
[profile apply:[isNotificationAttribute withValue:configDict[@"isNotification"]]];
}
return profile;
}
+ (CLLocation *)locationForDictionary:(NSDictionary *)locationDict
{
if (locationDict == nil) {