Notice
Recent Posts
Archives
Today
Total
«   2024/06   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Recent Comments
관리 메뉴

우당탕탕 개발일지

[Unity] 메일 문의하기 본문

Unity

[Unity] 메일 문의하기

devchop 2023. 8. 8. 13:22

게임을 플레이하다보면 문의사항이 필요한데, 자동으로 자신의 닉네임이나 아이디, 디바이스 정보를 함께 보내주면 매우 편리하다. 디바이스에 설치되어있는 메일 어플을 켜고 , 받는이와 유저정보를 미리 넣어주면 된다. 유저는 질문사항만 간단하게 넣거나 메일 어플을 이용해 사진을 첨부할 수도 있다. 참 쉽죠잉? 

using CodeStage.AntiCheat.ObscuredTypes;
using UnityEngine;
using UnityEngine.Networking;

public class RequestMail
{
    public string userEmail;
    public string userNickname;
    public string userIndate;
    public string title;
    public string body;


    public RequestMail(string email = "", string title = "", string body = "")
    {
        var storage = PlayerStorage.GetInstance();
        userEmail = email;
        userNickname = storage.account.nickname; //유저의 닉네임을 넣어준다
        userIndate = storage.account.inDate; //유저의 uid를 넣어준다
        this.title = title;
        this.body = body;
    }
}

public class MailUtility 
{
    static ObscuredString email_Google = "yourGoogelEmail";
    

    public static void SendWithApplication()
    {
        RequestMail mail = new RequestMail();
        string subject = GetDefaultTitle(mail.userNickname);
        string body = GetDefaultBody(mail);

        Application.OpenURL("mailto:" + email_Google + "?subject=" + subject + "&body=" + body);
    }

    static string GetDefaultTitle(string nick)
    {
        return EscapeURL
            (

            "[" + nick + "]"

            );
    }

    static string GetDefaultBody(RequestMail mail)
    {
        return EscapeURL
            (
             "\n\n" +
             "________\n\n" +
             "Device Model : " + SystemInfo.deviceModel + "\n" +
             "Device OS : " + SystemInfo.operatingSystem + "\n" +
             "UserNickname :" + mail.userNickname + " (" + mail.userIndate + ")\n\n" +
             "________\n"
            );

    }

    static string EscapeURL(string URL)
    {
        return UnityWebRequest.EscapeURL(URL).Replace("+", "%20");
    }
}