Beispiel #1
0
    public void UpdateMessage(string message)
    {
        if (PeerType == 2)
        {
            StatusText.GetComponent <Text>().text = message;
            Debug.Log(message);

            databaseReference = FirebaseDatabase.DefaultInstance.RootReference;
            databaseReference.Child("Users").Child(authReference.CurrentUser.UserId).Child("Connections").Push().Child("shared_card_id").SetValueAsync(message);

            DoneText.SetActive(true);
            DoneText.GetComponent <Text>().text = "New connection Formed !!";
            ViewProfileBtn.SetActive(true);
            PlayerPrefs.SetString("CARD_ID", message);
        }
    }
Beispiel #2
0
    public void OnSend()
    {
        if (PeerType == 1)
        {
            string Smsg = cardToBeSentId;
            Debug.Log("Message sending : " + Smsg);
            activityContext.Call("SendMsg", Smsg);

            StatusText.SetActive(false);
            PeerListPanel.SetActive(false);
            SendProfileBtn.SetActive(false);
            SelectedCard.SetActive(false);
            DoneImage.SetActive(true);
            DoneText.SetActive(true);

            StartCoroutine(WaitAndLoad());
        }
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        authReference = Firebase.Auth.FirebaseAuth.DefaultInstance;
        authUser      = authReference.CurrentUser;
        if (authUser == null)
        {
            SceneManager.LoadScene("LoginScene");
        }
        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://card-677f1.firebaseio.com/");

        databaseReference = FirebaseDatabase.DefaultInstance.RootReference;
        Query query = databaseReference.Child("cards").OrderByChild("user_id").EqualTo(authUser.UserId);

        query.GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                print("ERROR");
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                // Do something with snapshot...
                foreach (DataSnapshot childSnaphot in snapshot.Children)
                {
                    Debug.Log(childSnaphot.Key.ToString());

                    downloadUrl = childSnaphot.Child("target_url").Value.ToString();

                    downloadUrls.Add(downloadUrl);
                    cardList.Add(childSnaphot.Key.ToString());
                }

                StartCoroutine(DownloadCard());
            }
        });

        activityClass   = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        activityContext = activityClass.GetStatic <AndroidJavaObject>("currentActivity");
        contextClass    = new AndroidJavaClass("android.content.Context");
        context         = activityContext.Call <AndroidJavaObject>("getApplicationContext");

        PeerType = 0;

        if (!Permission.HasUserAuthorizedPermission(Permission.CoarseLocation))
        {
            Permission.RequestUserPermission(Permission.CoarseLocation);
            //Permission.RequestUserPermission(Permission.FineLocation);
        }

        PeerListPanel.SetActive(false);
        StatusText.SetActive(false);
        SendProfileBtn.SetActive(false);
        Image.SetActive(false);
        DoneImage.SetActive(false);
        DoneText.SetActive(false);
        ConnectedImage.SetActive(false);
        CardListPanel.SetActive(false);
        SelectedCard.SetActive(false);
        ViewProfileBtn.SetActive(false);

        //		WifiStatus.text = "Device Ready";
        Debug.Log("Device Ready");
    }