iOSMobSDKImpl.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using UnityEngine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace cn.sharesdk.unity3d {
  7. #if UNITY_IPHONE || UNITY_IOS
  8. public class iOSMobSDKImpl : MobSDKImpl {
  9. private string _callbackObjectName = "Main Camera";
  10. [DllImport("__Internal")]
  11. private static extern void __iosMobSDKGetPolicy(bool type,string language, string observer);
  12. [DllImport("__Internal")]
  13. private static extern string __iosMobSDKGetCurrentLanguage();
  14. [DllImport("__Internal")]
  15. private static extern void __iosMobSDKSubmitPolicyGrantResult(bool granted);
  16. [DllImport("__Internal")]
  17. private static extern void __iosMobSDKSetAllowDialog(bool allowDialog);
  18. [DllImport("__Internal")]
  19. private static extern void __iosMobSDKSetPolicyUI(String backgroundColorRes, String positiveBtnColorRes, String negativeBtnColorRes);
  20. public iOSMobSDKImpl(GameObject go) {
  21. try {
  22. _callbackObjectName = go.name;
  23. } catch(Exception e) {
  24. Console.WriteLine("{0} Exception caught.", e);
  25. }
  26. }
  27. public override string getPrivacyPolicy(bool url, string language) {
  28. __iosMobSDKGetPolicy(url, language, _callbackObjectName);
  29. return "";
  30. }
  31. public override string getDeviceCurrentLanguage() {
  32. return __iosMobSDKGetCurrentLanguage();
  33. }
  34. public override Boolean submitPolicyGrantResult(bool granted) {
  35. __iosMobSDKSubmitPolicyGrantResult(granted);
  36. return true;
  37. }
  38. public override void setAllowDialog(bool allowDialog) {
  39. __iosMobSDKSetAllowDialog(allowDialog);
  40. }
  41. public override void setPolicyUi(string backgroundColorRes, string positiveBtnColorRes, string negativeBtnColorRes) {
  42. __iosMobSDKSetPolicyUI(backgroundColorRes, positiveBtnColorRes, negativeBtnColorRes);
  43. }
  44. }
  45. #endif
  46. }