-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #994 from bounswe/mobile/notification-implementation
Implement notifaction endpoint request
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
app/mobile/Assets/Scripts/NotificationRequests/GetNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
app/mobile/Assets/Scripts/NotificationRequests/GetNotification.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.