Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by siddharth3322 · Apr 30, 2016 at 11:29 AM · unity 5iospush notificationdeviceuniqueidentifier

Device Token requirement in push notification

I actually implemented push notification service into my game but I have some questions in my mind those I want to clear.

Implementation totally done on our custom server so not used any third party service help in this. I have used core Unity push notification code for this purpose.

NotificationServices.deviceToken

After registration was complete, I need to add deviceToken to web server. Why I need to do this? I can't able to get this concept.

If I add SystemInfo.deviceUniqueIdentifier then it will not able to send any push notification. It can only able to work with deviceToken.

Please share your suggestions with this.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Olly · Sep 11, 2016 at 11:49 AM 0
Share

I have the same problem.

NotificationServices.deviceToken is for iOS only but it always returns null for me. (Great instructions about how to setup push notifications with certificates here: https://github.com/argon/node-apn/wiki/Preparing-Certificates)

For Andorid; I can't see any way to get push notification device token.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DVFrance · Dec 21, 2016 at 03:28 PM

Hello I'm working on it and it's drive me crazy. I also need device token for android and I can't find a way to know it, I tried with SystemInfo.deviceUniqueIdentifier on this http://www.pushwatch.com/gcm/. And It doesn't work.

Any idea will be helpfull ! Tks

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bimaokai · Oct 12, 2020 at 01:04 PM

,Hi, I know this is very old but maybe it helps somebody.

In the Start Method I am calling this one:

 UnityEngine.iOS.NotificationServices.RegisterForNotifications(
                 UnityEngine.iOS.NotificationType.Alert |
                 UnityEngine.iOS.NotificationType.Badge |
                 UnityEngine.iOS.NotificationType.Sound);
 

Then in update I register the device ID to my own web service:

 public void RegisterClient()
     {
         if (!tokenSent && !workingOnRegistering)
         {
             workingOnRegistering = true;
             string theToken = "ABCDEFG......";
             byte[] token = UnityEngine.iOS.NotificationServices.deviceToken;
             if (token != null)
             {
                 theToken = System.BitConverter.ToString(token).Replace("-", "");
                 tokenSent = true;
             }
                 
 
             string url = String.Format("myURL");
             UnityWebRequest webRequest = new UnityWebRequest(url, "POST");            
             byte[] encodedPayload = new System.Text.UTF8Encoding().GetBytes("{\"deviceID\":\""+theToken+"\"}");
 
             webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(encodedPayload);
             webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
             webRequest.SetRequestHeader("Content-Type", "application/json");
             webRequest.SetRequestHeader("cache-control", "no-cache");
 
             UnityWebRequestAsyncOperation requestHandel = webRequest.SendWebRequest();
             requestHandel.completed += delegate (AsyncOperation pOperation) {
                 /*Debug.Log(webRequest.responseCode);
                 Debug.Log(webRequest.downloadHandler.text);*/
             };
             workingOnRegistering = false;
         }
     }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity and ARkit Plugin - Please Help 0 Answers

image got pixelated on ios device 0 Answers

How to load tdb file in unity? 1 Answer

How to solve issues between Unity and Xcode? 0 Answers

IOS Build from unity3d give "error: linker command failed with exit code 1 (use -v to see invocation)" error 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges