unity调用苹果端方法

 

unity端

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

苹果端

extern "C" {

 //const char * Get_UUID_By_KeyChain()

 // {

      // Unity 端调用到iOS端

 //     char const* pch = "abc";

 //     return pch;

  //}

char * Get_UUID_By_KeyChain() {

   // NSString * str = @"Sheldon";

    NSString* str = [BGKeychainTool getDeviceIDInKeychain];

        char * x = (char *)malloc(strlen([str UTF8String]) + 1);

        strcpy(x, [str UTF8String]);

        return x;

}

}

posted @ 2021-08-19 10:16  T驱动  阅读(164)  评论(0编辑  收藏  举报