Skip to content

Commit

Permalink
Merge pull request #994 from bounswe/mobile/notification-implementation
Browse files Browse the repository at this point in the history
Implement notifaction endpoint request
  • Loading branch information
egeek259 authored Dec 12, 2023
2 parents 3186ecc + cb99eed commit bdf068b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/mobile/Assets/Scripts/NotificationRequests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions app/mobile/Assets/Scripts/NotificationRequests/GetNotification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

namespace NotificationRequests
{
public class GetNotification : MonoBehaviour
{
private Dictionary<string,string> queryParams = new Dictionary<string, string>();

private void Start()
{
queryParams.Add("isRead ", "true");
Init();
}

public void Init()
{
string url = AppVariables.HttpServerUrl + "/notification/get-notifications" +
DictionaryToQueryParameters.DictionaryToQuery(queryParams);
StartCoroutine(Get(url));
}


IEnumerator Get(string url)
{
var request = new UnityWebRequest(url, "GET");
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Authorization", PersistenceManager.UserToken);
yield return request.SendWebRequest();
string response = "";
if (request.responseCode == 200)
{
response = request.downloadHandler.text;
Debug.Log("Success to get notifications: " + response);
}
else
{
Debug.Log("Error to get notifications: " + response);
}
request.downloadHandler.Dispose();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bdf068b

Please sign in to comment.