Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Release AppMetrica Push Unity Plugin 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliaksei Nestsiarovich committed Aug 15, 2022
1 parent c1b7f2e commit 722c14b
Show file tree
Hide file tree
Showing 34 changed files with 1,718 additions and 119 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
ProjectSettings/

# Autogenerated VS/MD solution and project files
*.csproj
Expand Down
Binary file modified AppMetricaPush.unitypackage
Binary file not shown.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Changelog

### Version 1.1.0
* Updated native SDKs *(iOS 1.3.0, Android 2.2.0)*
* Supported Unity 2022.1
* Fixed plugin working on devices with Android 7 and below due to a error `java.lang.NoClassDefFoundError: android.app.NotificationChannel`

### Version 1.0.0
* Updated native SDKs *(iOS 1.1.1, Android 2.1.1)*
* Supported [EDM4U](https://github.com/googlesamples/unity-jar-resolver) for dependency resolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class AppMetricaPush : MonoBehaviour
{
public const string VERSION = "1.0.0";
public const string VERSION = "1.1.0";

private static bool _isInitialized = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<dependencies>
<androidPackages>
<androidPackage spec="com.yandex.android:mobmetricapushlib:2.1.1"/>
<androidPackage spec="com.yandex.android:appmetricapush-plugin:2.2.1"/>
<androidPackage spec="com.google.firebase:firebase-messaging:22.0.0"/>
<androidPackage spec="com.google.android.gms:play-services-base:17.5.0"/>
<androidPackage spec="androidx.legacy:legacy-support-v4:1.0.0"/>
<androidPackage spec="com.yandex.android:mobmetricapushlib:2.2.0" />
<androidPackage spec="com.yandex.android:appmetricapush-plugin:2.3.0" />
<androidPackage spec="com.google.firebase:firebase-messaging:22.0.0" />
<androidPackage spec="com.google.android.gms:play-services-base:17.5.0" />
<androidPackage spec="androidx.legacy:legacy-support-v4:1.0.0" />
</androidPackages>
<iosPods>
<iosPod name="YandexMobileMetricaPush" version="1.1.1" minTargetSdk="9.0"/>
<iosPod name="YandexMobileMetricaPush" version="1.3.0" minTargetSdk="9.0" />
</iosPods>
</dependencies>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#import "UnityAppController.h"
#import "YMMBridge.h"
#import "YMPUTokenStorage.h"
#import "YMPUUtils.h"
#import <objc/runtime.h>

// TODO: Describe UIApplicationDelegate hijacking here.
Expand Down Expand Up @@ -63,6 +65,7 @@ - (void)ymp_application:(UIApplication *)application didRegisterForRemoteNotific
// We have to ensure that AppMetrica activated here
[YMPYandexMetricaPush setDeviceTokenFromData:deviceToken];
}
[YMPUTokenStorage saveToken:deviceToken];

// Call the original method
[self ymp_application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
Expand Down Expand Up @@ -171,6 +174,19 @@ void ymp_saveActivationConfigurationJSON(char *configurationJSON)
[[NSUserDefaults standardUserDefaults] setObject:JSONString forKey:kYMPUserDefaultsConfigurationKey];
}

char *ymp_getToken()
{
NSString *token = [YMPUUtils stringForTokenData:[YMPUTokenStorage getToken]];

char *result = NULL;
if (token != NULL) {
const char *cToken = [token UTF8String];
result = (char *)malloc(strlen(cToken) + 1);
strcpy(result, cToken);
}
return result;
}

char *ymp_getLibraryVersion()
{
NSString *version = [[NSString alloc] initWithFormat:@"%d.%d%d", YMP_VERSION_MAJOR, YMP_VERSION_MINOR, YMP_VERSION_PATCH];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Version for Unity
* © 2022 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

#import <Foundation/Foundation.h>

@interface YMPUTokenStorage : NSObject

+ (void)saveToken:(NSData *)token;
+ (NSData *)getToken;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Version for Unity
* © 2022 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

#import "YMPUTokenStorage.h"

@implementation YMPUTokenStorage

NSString *const kYMPUUserDefaultsTokenKey = @"com.yandex.mobile.metrica.push.unity.PushToken";

+ (void)saveToken:(NSData *)token
{
[[NSUserDefaults standardUserDefaults] setObject:token forKey:kYMPUUserDefaultsTokenKey];
}

+ (NSData *)getToken
{
return [[NSUserDefaults standardUserDefaults] dataForKey:kYMPUUserDefaultsTokenKey];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Version for Unity
* © 2022 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

@interface YMPUUtils : NSObject

+ (NSString *)stringForTokenData:(NSData *)deviceToken;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Version for Flutter
* © 2022 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

#import "YMPUUtils.h"

@implementation YMPUUtils

+ (NSString *)stringForTokenData:(NSData *)deviceToken
{
if (deviceToken.length == 0) {
return nil;
}

const char *bytes = [deviceToken bytes];
NSMutableString *token = [NSMutableString string];
for (NSUInteger i = 0; i < deviceToken.length; ++i) {
[token appendFormat:@"%02.2hhx", bytes[i]];
}
return [token copy];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class YandexMetricaPushAndroid : IYandexMetricaPush

#region IYandexMetricaPush implementation

private readonly AndroidJavaClass metricaPushClass = new AndroidJavaClass ("com.yandex.metrica.push.YandexMetricaPush");
private readonly AndroidJavaClass metricaPushClass =
new AndroidJavaClass ("com.yandex.metrica.push.plugin.YandexMetricaPushWrapper");

public void Initialize ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
using System;

#if UNITY_IPHONE || UNITY_IOS

Expand All @@ -19,6 +15,9 @@ public class YandexMetricaPushIOS : IYandexMetricaPush
[DllImport ("__Internal")]
private static extern void ymp_saveActivationConfigurationJSON (string configurationJSON);

[DllImport ("__Internal")]
private static extern string ymp_getToken ();

#region IYandexMetricaPush implementation

public void Initialize ()
Expand All @@ -32,22 +31,14 @@ public void Initialize ()

public string Token {
get {
return DeviceTokenString (UnityEngine.iOS.NotificationServices.deviceToken);
return ymp_getToken();
}
}

private void ProcessConfigurationUpdate (YandexAppMetricaConfig config)
private void ProcessConfigurationUpdate(YandexAppMetricaConfig config)
{
// Yandex AppMetrica Unity Plugin JSON Utils are used here.
ymp_saveActivationConfigurationJSON (YMMJSONUtils.JSONEncoder.Encode (config.ToHashtable ()));
}

private string DeviceTokenString (byte[] data)
{
if (data == null || data.Length == 0) {
return null;
}
return BitConverter.ToString (data).Replace ("-", string.Empty);
ymp_saveActivationConfigurationJSON(YMMJSONUtils.JSONEncoder.Encode(config.ToHashtable()));
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.3709941, g: 0.3785282, b: 0.35739636, a: 1}
m_IndirectSpecularColor: {r: 0.3731316, g: 0.38074902, b: 0.3587254, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &4
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
Expand All @@ -54,15 +54,14 @@ LightmapSettings:
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 12
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
Expand All @@ -77,28 +76,20 @@ LightmapSettings:
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRFilteringMode: 2
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 490462748}
m_UseShadowmask: 0
--- !u!196 &5
NavMeshSettings:
serializedVersion: 2
Expand All @@ -118,73 +109,9 @@ NavMeshSettings:
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!850595691 &490462748
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Settings.lighting
serializedVersion: 4
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentMIS: 0
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
--- !u!1001 &852060421
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -310,7 +237,6 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
Expand Down Expand Up @@ -362,10 +288,9 @@ Camera:
m_ClearFlags: 2
m_BackGroundColor: {r: 1, g: 1, b: 1, a: 0.019607844}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
Expand Down Expand Up @@ -403,7 +328,6 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
Expand Down
Loading

0 comments on commit 722c14b

Please sign in to comment.