Advertisement
Guest User

TestCodeObjectC

a guest
Nov 13th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. #import "AppDelegateListener.h"
  2.  
  3. @interface AppDelegateListenerTest : NSObject <AppDelegateListener>
  4. @property NSString *_goName;
  5. @property NSString *_methodName;
  6. @end
  7.  
  8. @implementation AppDelegateListenerTest
  9.  
  10. static AppDelegateListenerTest *_instance = nil;
  11.  
  12. + (void)load {
  13. if(!_instance) {
  14. _instance = [[AppDelegateListenerTest alloc] init];
  15. }
  16. }
  17.  
  18. - (id)init {
  19. self = [super init];
  20. if(!self)
  21. return nil;
  22.  
  23. _instance = self;
  24.  
  25. // register to unity
  26. UnityRegisterAppDelegateListener(self);
  27.  
  28. return self;
  29. }
  30.  
  31. - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSNotification*)notification {
  32. NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken was called!");
  33. }
  34.  
  35. - (void)didFailToRegisterForRemoteNotificationsWithError:(NSNotification*)notification {
  36. NSLog(@"didFailToRegisterForRemoteNotificationsWithError was called!");
  37. }
  38.  
  39. - (void)didReceiveRemoteNotification:(NSNotification*)notification {
  40. NSLog(@"didReceiveRemoteNotification was called!");
  41. }
  42.  
  43. - (void)didReceiveLocalNotification:(NSNotification*)notification {
  44. NSLog(@"didReceiveLocalNotification was called!");
  45. }
  46.  
  47. - (void)onOpenURL:(NSNotification*)notification {
  48. NSLog(@"onOpenURL was called!");
  49. NSURL *url = notification.userInfo[@"url"];
  50. NSString *urlStr =[url absoluteString];
  51. const char *mess = [urlStr cStringUsingEncoding:NSASCIIStringEncoding];
  52. UnitySendMessage("ScriptObject", "OnDeepLinkURLOpened", mess);
  53. }
  54.  
  55. - (void)applicationDidReceiveMemoryWarning:(NSNotification*)notification {
  56. NSLog(@"applicationDidReceiveMemoryWarning was called!");
  57. }
  58.  
  59. - (void)applicationSignificantTimeChange:(NSNotification*)notification {
  60. NSLog(@"applicationSignificantTimeChange was called!");
  61. }
  62.  
  63. - (void)applicationWillChangeStatusBarFrame:(NSNotification*)notification {
  64. NSLog(@"applicationWillChangeStatusBarFrame was called!");
  65. }
  66.  
  67. - (void)applicationWillChangeStatusBarOrientation:(NSNotification*)notification {
  68. NSLog(@"applicationWillChangeStatusBarOrientation was called!");
  69. }
  70.  
  71. @end
  72.  
  73. extern "C"{
  74. void SetupInstance(const char *goName){
  75. AppDelegateListenerTest *test = [AppDelegateListenerTest shared];
  76. test._goName = [NSString stringWithUTF8String:goName];
  77. test._methodName = [NSString stringWithUTF8String:goName];
  78. }
  79.  
  80. const char *GetGameObjectName(){
  81. AppDelegateListenerTest *test = [AppDelegateListenerTest shared];
  82.  
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement