示例#1
0
    void Awake()
    {
        //make sure we only have one object with this Gamedonia script at any time
        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        _instance     = this;
        notifications = new List <Dictionary <string, object> >();
        DontDestroyOnLoad(this);

                #if UNITY_EDITOR
                #elif UNITY_IOS
        if ((notificationType & RemoteNotificationType.Badge) != 0 && clearBadgeOnActivate)
        {
            ClearBadge();
        }
                #endif


        GDService service = new GDService();
        service.ProfileEvent += new ProfilerEventHandler(Profile);
        GamedoniaDevices.services.Add(service);

        GamedoniaDevices.GetProfile(OnGetProfile);
    }
示例#2
0
    private static void RegisterDeviceAfterLogin(Action <bool> callback)
    {
        if (Gamedonia.INSTANCE.IsDeviceRegisterNeeded())
        {
            GamedoniaDevices.GetProfile(
                delegate(bool successDevProfile, GDDeviceProfile device) {
                if (successDevProfile)
                {
                    switch (device.deviceType)
                    {
                    case "ios":
                    case "android":
                        if (GamedoniaUsers.me == null)
                        {
                            GamedoniaUsers.GetMe(
                                delegate(bool success, GDUserProfile profile) {
                                if (success)
                                {
                                    GamedoniaDevices.device.uid = GamedoniaUsers.me._id;
                                    GamedoniaDevices.Register(device,
                                                              delegate(bool successRegister) {
                                        if (callback != null)
                                        {
                                            callback(successRegister);
                                        }
                                    }
                                                              );
                                }
                                else
                                {
                                    if (callback != null)
                                    {
                                        callback(success);
                                    }
                                }
                            }
                                );
                        }
                        else
                        {
                            GamedoniaDevices.device.uid = GamedoniaUsers.me._id;
                            GamedoniaDevices.Register(device,
                                                      delegate(bool successRegister) {
                                if (callback != null)
                                {
                                    callback(successRegister);
                                }
                            }
                                                      );
                        }
                        break;

                    default:
                        if (callback != null)
                        {
                            callback(successDevProfile);
                        }
                        break;
                    }
                }
                else
                {
                    Debug.LogWarning("The device has not been registered due to an error");
                    if (callback != null)
                    {
                        callback(successDevProfile);
                    }
                }
            }
                );
        }
        else
        {
            if (callback != null)
            {
                callback(true);
            }
        }
    }