DeepLinkAppDelegate Created by Илья on 29 05 2019 import DeepLinkAppDe

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// DeepLinkAppDelegate.m
//
//
// Created by Илья on 29/05/2019.
//
#import "DeepLinkAppDelegate.h"
IMPL_APP_CONTROLLER_SUBCLASS(DeepLinkAppDelegate)
@implementation DeepLinkAppDelegate
- (void) deepLinkIsAlive
{
if (_lastURL)
{
const char *URLString = [_lastURL cStringUsingEncoding:NSASCIIStringEncoding];
// UnitySendMessage("_DeepLinkReceiver", "URLOpened", URLString);
UnitySendMessage("_DeepLinkReceiver", "URLOpened", "111");
}
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
printf("Deeplinkurl--App");
_lastURL = url.absoluteString;
const char *URLString = [url.absoluteString cStringUsingEncoding:NSASCIIStringEncoding];
UnitySendMessage("_DeepLinkReceiver", "URLOpened", "222");
return [super application:app openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (launchOptions[UIApplicationLaunchOptionsURLKey] != nil) {
NSURL *url = launchOptions[UIApplicationLaunchOptionsURLKey];
_lastURL = url.absoluteString;
const char *URLString = [url.absoluteString cStringUsingEncoding:NSASCIIStringEncoding];
UnitySendMessage("_DeepLinkReceiver", "URLOpened", "333");
}
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (char *) deepLinkURL
{
NSString *str = _lastURL ? _lastURL : @"";
char * result = malloc(sizeof(char) * str.length);
strcpy(result, [str UTF8String]);
return result;
}
@end