Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] UTNotifications - Professional Cross Platform Push Notifications and More

Discussion in 'Assets and Asset Store' started by Yuriy-Ivanov, Jun 12, 2015.

  1. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @Martin_k,

    1. The ticker is gone since Android 5.0, and user have to install a special app to get it back. See http://www.androidpolice.com/2014/1...cation-ticker-is-gone-and-thats-kind-of-dumb/. It has nothing to do with your app's or UTNotifications' code.

    2. How can I make a bahaviour, that when I press notification, it cleans up?
    It does clean up now (if not - please let me know with all the details - especially the Android version you're testing with), but also opens the main activity. If you want to change that behaviour, you'll have to modify the Android native plugin:
    Import it (Assets/UTNotifications/Editor/Android/NativePluginSource) into AndroidStudio, then in file
    NotificationIntentService.java, see method onHandleIntent. Modify it as you like.
    After you modified the plugin, run gradle "deploy" task to build and deploy the plugin into Unity Android plugins folder.

    Best regards,
    Yuriy, Universal Tools team.
     
  2. Martin_k

    Martin_k

    Joined:
    Feb 19, 2015
    Posts:
    6
    1. ticker is a text, shown in top panel, when notification apears, I had it on Huawei Mate 8 Android 6.0 and others.

    http://www.guidingtech.com/assets/postimages/2015/07/notification-on-android-lillipop-9.png

    Notification.Builder builder = new Notification.Builder(context);

    builder.setContentIntent(contentIntent)
    .setWhen(System.currentTimeMillis())
    .setContentTitle(title)
    .setContentText(message)
    .setTicker(ticker);

    2. You are right moustly. On Sony Experia Android 5.1 it doesn't cleans up.
     
  3. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Martin_k,

    Sorry for a misunderstanding. You can easily add ticker on your own by modifying the native plugin: see Assets/UTNotifications/Editor/Android/NativePluginSource/utnotifications/src/main/java/universal/tools/notifications/Manager.java, private static Notification prepareNotification(Context context, String title, String text, int id, String notificationProfile, Bundle userData, Bitmap bitmap):
    Code (CSharp):
    1.         NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
    2.                 .setSmallIcon(icon)
    3.                 .setContentTitle(title)
    4.                 .setDefaults((soundUri == null) ? NotificationCompat.DEFAULT_ALL : NotificationCompat.DEFAULT_LIGHTS | NotificationCompat.DEFAULT_VIBRATE)
    5.                 .setContentText(text)
    6.                 .setContentIntent(contentIntent)
    7.                 .setAutoCancel(true);
    You can supply the ticker value as userData argument. Then run gradle "deploy" task, as described in my previous message.

    2. You are right moustly. On Sony Experia Android 5.1 it doesn't cleans up.
    Thank you for these details, I added an appropriate ticket into our internal issue tracking system: we'll try to reproduce and fix it. If you know any other devices affected by it, please let me know. Thanks.

    Best regards,
    Yuriy, Universal Tools team.
     
  4. b-kevin

    b-kevin

    Joined:
    Dec 17, 2016
    Posts:
    2
    Hi Yuriy,

    Thanks for a great product, it works really well.

    I have a question about userData on Android. I am posting a notification using the following json:

    {
    "registration_ids":["<id>"],
    "data": {
    "title":"Test",
    "text":"Test notification",
    "accountid":"166"
    }
    }


    I am expecting the user data 'accountid' to be available in the receivedNotification function. Eg

    notificationsManager.OnNotificationsReceived += (receivedNotifications) =>
    {

    foreach (var notification in receivedNotifications)
    {
    Debug.Log("user data: " + notification.userData["accountid"] );
    Debug.Log("title: " + notification.title);
    Debug.Log("text: " + notification.text + " received/triggered");
    }
    };


    However, the above code results is null pointer exception on notification.userData

    I've searched the docs and I can't see what I'm doing wrong? Any help you can provide will be much appreciated.

    Thanks,

    Kevin

     
  5. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @b-kevin,

    I just checked with your JSON Payload - it works completely fine and
    Code (CSharp):
    1. notification.userData["accountid"]
    returns "166" (checked using appropriately modified DemoServer and the sample scene).
    Please check that
    1. Advanced -> Push Payload Format (FCM, ADM, WNS) -> User data parent (opt) is set to "data/"
    2. The payload you showed is exactly what's sent to FCM servers.
    3. NullPointerException refers to the line
    Code (CSharp):
    1. Debug.Log("user data: " + notification.userData["accountid"] );
    (also please check and inform me what exactly is null here - notification or notification.userData)

    Best regards,
    Yuriy, Universal Tools team.
     
  6. b-kevin

    b-kevin

    Joined:
    Dec 17, 2016
    Posts:
    2
    Thanks Yuriy,

    I think the problem was User data parent (opt) is set to "data/" it seems to be working now. Thanks for your help.
     
  7. bluhomes

    bluhomes

    Joined:
    Dec 17, 2012
    Posts:
    2
    Hi Yuriy --

    I have push notifications working great using your product, thank you!

    However I am trying to open a web page on the iPhone when the user clicks on the push notification, rather than opening the app. I am using the Manager's OnNotificationClicked event.

    I have a call to Application.OpenURL("website name") in the corresponding OnNotificationClicked method, and the method is definitely being called. I'm sure that I need to do more than just call OpenURL(), I'm just not sure exactly what.

    Are there any examples that you could point me to, that would show how to accomplish this?

    Thanks in advance.
     
  8. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @bluhomes ,
    First of all, thank you for using UTNotifications!

    Unfortunately, any C# code is called only when your app is running. So with OnNotificationClicked you'll be able to call Application.OpenURL to open the URL indeed, but the app will be started/brought to foreground anyway. On Android you can redefine the notification click behaviour as you like in UTNotifications native plugin (see Assets/UTNotifications/Editor/Android/NativePluginSource/utnotifications/src/main/java/universal/tools/notifications/NotificationIntentService.java), but for iOS it's unfortunately not that easy: 1) You'll have to modify the objective-c code of the project generated by Unity 2) your app may still be started (not sure).

    But if you don't mind that your app is started before opening the URL, using Application.OpenURL in OnNotificationClicked should work well. If not, please make sure (f.e. with debugging or logs) that OnNotificationClicked is called.

    Please let me know if you need any further assistance (if it's the case with OnNotificationClicked, please also show how and when you subscribe to that event, and how you call Application.OpenURL).

    Best regards,
    Yuriy, Universal Tools team.
     
  9. bluhomes

    bluhomes

    Joined:
    Dec 17, 2012
    Posts:
    2
    Hi Yuriy --

    Thanks for getting back to me. I was afraid I might have to modify the objective-c code! I will look into doing that.

    Best,

    Jeremy
     
  10. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Jeremy,

    I checked a little bit, and you seem not to be able to open URL on notification click without starting the app on iOS, f.e. see http://stackoverflow.com/questions/...-uilocal-notification-rather-than-opening-app. So using UTNotifications' OnNotificationClicked may be the best available option on iOS (and you will not have to manually modify any Objective-C code). Again, if that option doesn't work for you, please describe it in details with pieces of code - as it should work.

    Best regards,
    Yuriy, Universal Tools team.
     
  11. Gulliver

    Gulliver

    Joined:
    Jan 8, 2013
    Posts:
    67
    Только-что купил. Похоже - лучшее что есть )
     
  12. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Спасибо за доверие! Мы же планируем продолжать улучшать ассет.
    И конечно же, в случае любых вопросов - не стесняйтесь обращаться на universal.tools.contact@gmail.com

    С наилучшими пожеланиями,
    Юрий, команда Universal Tools.
     
  13. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    178
    Hi Yuriy,
    I am new to push notifications. And just starting to think about it. I came across this post and it seems like you have the best app from all of the feedback.
    My question is very very basic.
    Where do the notifications get created (in the UTNotifications??) and what server do they get housed on?

    Thanks for your answer and the lesson to this notification beginner.
     
  14. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @TGKG ,

    There are two main kinds of notifications: local and push. For a user they look the same, but local notifications are scheduled to be shown at specific time (possibly repeating) by a client application itself (f.e. see UTNotifications.Manager.ScheduleNotification and UTNotifications.Manager.ScheduleNotificationRepeating). Push notifications, though, always originate from a server ("pushed" by it). You can use any server you like for it, and any server language - usually your game server sends push notifications. There are also 3rd party services, which provide APIs or admin panels for sending push notifications (for money, or free) - f.e. https://onesignal.com/. These services are usually well-compatible with UTNotifications as they rely on the same system push notifications providers internally (Google Firebase Cloud Messaging - FCM, Apple Push Notification Service - APNS and so on). UTNotifications are supplied with DemoServer source code - a java-written web-server which shows how to send push notifications to each of the push notifications providers. It's not supposed to be used in production directly, as it doesn't provide any security and so on, but it's useful for configuring/testing push notifications and helps you to implement push notifications on your own server. Also, see our official manual, especially section "Push Notifications Overview".

    Best regards,
    Yuriy, Universal Tools team.
     
  15. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    178
    Thank you for the quick reply
    If I understand correctly. I can embed "local notifications" into my game code using UTNotifications, complete with an embedded message and schedule, etc.
    or
    I can "push" notifications by having UTNotifications embedded into my game and using someone else's software to create the message and using someones else's server to send the message. Is that a correct simplified description?

    I will also read the manual to get a better understanding.
     
  16. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Basically correct, but with push notifications "someone else's software" and "someone else's server" can be (and most often are) "your own software" and "your own server".

    Best regards,
    Yuriy, Universal Tools team.
     
  17. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    178
    When you say "your own software", do you mean UTNotifications or something else?

    Thank you for the quick lesson
     
  18. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @TGKG ,
    Sorry for a late answer (it seems that I've not received an email from Unity about your new reply).

    By "your own software" I mean your own software - a piece of server code you've written on your own or a server library you integrated. Sending push notifications from a server is a really simple thing (except of, probably, APNS, but it is also not really difficult). UTNotifications' DemoServer is a good example on how it can be done. But if you don't have a game server yet, the simplest option may be indeed to use a free OneSignal service, which is easily integrated with UTNotifications.

    Best regards,
    Yuriy, Universal Tools team.
     
  19. sidebolt

    sidebolt

    Joined:
    Oct 3, 2016
    Posts:
    10
    Hi Yurity,

    Sorry if this has been answered, 368 messages is a lot to read. I am using your plugin for iOS and on iOS native when you register for push notifications the callback informs you whether the registration was successful or not. Usually in cases where it is unsuccessful it means the player has disabled push notifications. The two callbacks are:

    Code (CSharp):
    1. - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    2.  
    3. - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
    Is it possible to get that information with your plugin? It looks like the OnSendRegistrationID event only sends the provider and the registration id as strings. Will there just be no response if the registration fails or will one or both of these fields be null?

    Thanks!
     
  20. sidebolt

    sidebolt

    Joined:
    Oct 3, 2016
    Posts:
    10
    I am having another issue on iOS. I am able to successfully register for push notifications and receive my registration ID. However, as soon as I trigger a notification from my server and the client receives it the app crashes with this traceback:

    If the app is open when I receive the notification the app crashes immediately. If the app is backgrounded then it crashes when I tap on the notification to open the app. So it crashes on resume. The traceback is the same in both circumstances. This is happening whether I register for the notification received event or not and it is happening both with my project and the demo project provided in the package.

    I am testing with Unity 5.5.0f3 for Mac on XCode 8.2.1. My device is an iPhone 6 running iOS 10.2.1.

    Any advice, workarounds, or thoughts would be appreciated. Thanks!

    EDIT: Should also mention we are using APNS2.
    EDIT2: Device is actually an iPhone 6
     
    Last edited: Feb 22, 2017
  21. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @sidebolt ,

    First of all, thank you for using UTNotifications!

    Let's start with more important thing: the crash. We tested with exactly the same environment (Unity 5.5.0f3, XCode 8.2.1, iOS 10.2.1) and were unable to reproduce the issue. From the stack trace you show, it seems like the crash happens inside of Unity code (UnitySendRemoteNotification), this is why we can't see the rest calls details in the stack.
    Can you please check if the same issue is reproduced with DemoServer we provide? What message payload are you sending?

    Now, regarding APNS registration failure handling. For development purposes, there are appropriate messages printed in that case (see IOSManagerImpl.cs, protected void LateUpdate()). But for production use there is indeed no API for getting such feedback. We thought about implementing it, but couldn't find any realistic use cases for that.
    So, f.e., requesting notifications permissions after a user decided to not receive them may cause your app to be denied by Apple to be published in AppStore. So doing any specific actions on APNS registration failure is not the best idea, as you can see. But if you really have a need in that functionality, we can implement it in one of the future releases.

    Best regards,
    Yuriy, Universal Tools team.
     
  22. sidebolt

    sidebolt

    Joined:
    Oct 3, 2016
    Posts:
    10
    Hi Yuriy,

    Thanks for your response! Turns out the implementation of our push notification server was altering a value in the message payload from a boolean to a string. We were able to resolve it. Oops... :oops:

    In regards to the APNS registration failure handling. We plan to detect when a player has turned off push notifications so that we can send a message to our server and record that the player has turned off push notifications. We were also going to display a pop up to the user at a certain point letting them know they are missing some functionality of the app by having them off. We are aware that apple returns a response indicating the player has turned off notifications when the server tries to send a push but sometimes this takes a significant time to process and apple will return that the push went through when it didn't. This can occur for several hours. It would be a better experience for the user if we knew more quickly.

    For now we will just rely on Apple's callback server side but I believe we would make use of the client side call back functionality. Thanks again for your response!
     
  23. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @sidebolt ,

    OK, I added this task to our task tracking system (we're going to handle registration failures on other platforms too, when possible).

    Best regards,
    Yuriy, Universal Tools team.
     
  24. nightac

    nightac

    Joined:
    Dec 6, 2013
    Posts:
    2
    Hello,
    i buy your plugin. i am good at php programming and i am trying to my custom json file for notifaciton data per user

    i read whole manuel i found m_webServerAddress parameter in the manuel but i am not clearly understand how could i use this paremeter and how it need json data format

    Could you explain a bit more please

    Thank you
     
  25. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @nightac ,

    First of all, thank you for using UTNotifications!

    Did you have a chance to take a look at the DemoServer source code? You can find the most interesting part of it in Assets/UTNotifications/Editor/DemoServer/src/DemoServer/PushNotificator.java. It's written in Java, but it should not be difficult to understand even if you don't know Java. m_webServerAddress variable makes sense only for the sample scene and DemoServer, it's just an address of the locally running DemoServer. When you have your own implementation of push notifications server side, you'll connect and use it in a different way (basically, it's up to you).
    Also, you can use of many PHP libraries working with push notifications services. F.e. you can take a look at https://github.com/coder966/FCMSimple, https://github.com/immobiliare/ApnsPHP, https://github.com/vladdnepr/adm-notify, https://github.com/andreabbondanza/windowsnotificationphp (but there is plenty others).

    Feel free to ask any specific questions you may have, I'm always happy to help!

    Best regards,
    Yuriy, Universal Tools team.
     
  26. chachi_app

    chachi_app

    Joined:
    Feb 9, 2017
    Posts:
    12
    Hi! I´m trying to receive Android (FCM) push notifications from my GameSparks server, but still not receive anything on my device. I´ve follow the steps:
    • Install your plugin.
    • Configure the project on Google, and Android FCM aplication with Cloud Messaging.
    • Attach the Server Key with GameSparks.
    • Load the google-services.json on client side
    • Set the SenderID with the FCM Project Number in client side
    • Launch client:
      • notificationsManager.Initialize(true, 0, false); returns TRUE
    >>>>> UTNotifications Initialize: True

    • Use the provider name and registrationID to register device on GameSparks
    • Gamesparks answers: registration succesfull, returns ID

    >>>>>>>>> Registering device succesfull xxxxxxxxxxxxxx


    • Send push message from GameSparks with Socket OFF and PushNotif ON
    • Nothing happens.
    Im not doing nothing more on client side. Have I to manage something more? Some routine for the Notification received?
    Any ideas?


    Thank u very much!
     
  27. chachi_app

    chachi_app

    Joined:
    Feb 9, 2017
    Posts:
    12
    It was my fault on server side! Thank u!
     
  28. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @vegusquiza ,

    I've just replied you by email, and then noticed your message here :)
    I'm glad that you sorted that out. Please let me know if you need any further assistance.

    Best regards,
    Yuriy, Universal Tools team.
     
  29. chachi_app

    chachi_app

    Joined:
    Feb 9, 2017
    Posts:
    12
    Thank u so much Yuriy! My FCN Android Push Notifications are working now! Yeah! Im managin IOS APNS crazy system now :) How can i know the APNS Registration ID Encoding (HEX or Base64) ? Somewhere in XCode?

    Thank u!
     
  30. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @vegusquiza ,

    Basically, it's up to you. APNS registration ids are actually binary tokens. In order to send them to your server, it's usually more convenient to encode those binary tokens as text, which is then decoded on a server side. So you just need to align it with the server - it should expect it to be decoded in the way how you encode the token on a client side. Most 3rd party services expect tokens to be encoded in HEX, but if you're writing your own server, you can choose anything. Base64 is just more compact.

    Best regards,
    Yuriy, Universal Tools team.
     
  31. TheADrain

    TheADrain

    Joined:
    Nov 16, 2016
    Posts:
    48
    Hi Yuriy,

    I'm hoping to be able to use your plugin to help me implement push notifications across iOS, Android and Kindle. I've been through the tutorial setup, however on both iOS and Android I'm not receiving the callback from OnSendRegistrationId, I'm using Firebase Cloud Messaging for Android and have the project setup and the server key and sender ID in my settings. Additionally, for iOS I have APNS enabled, the correct certificate, and have definitely enabled it in UTNotification settings.

    I'm using the latest version of UTNotifications, along with Unity 5.5

    Thanks.
     
    Last edited: Mar 13, 2017
  32. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @TheADrain ,

    Please select Android as a target platform and do: Unity menu -> Assets -> Play Services Resolver -> Android Resolver -> Resolve Client Jars. If it doesn't help, please check Unity console on any errors and send them to universal.tools.contact@gmail.com if any. Also send a list of all files and folders in your Assets/Plugins/Android.

    With iOS it's not so clear. Could you please send me a screenshot of your UTNotifications settings? Also please open the generated iOS project in Xcode and send me a screenshot of "Capabilities" tab.

    Best regards,
    Yuriy, Universal Tools team.
     
  33. TheADrain

    TheADrain

    Joined:
    Nov 16, 2016
    Posts:
    48
    I've managed to solve the problem with IOS, thanks for the quick response. For IOS it was that the provisioning profile hadn't been updated and cloud build was putting out builds with remote notifications disabled.

    For Android, I'm pulling this from the adb log:

    I/dalvikvm( 9093): Could not find method com.google.android.gms.common.GoogleApiAvailability.getInstance, referenced from method universal.tools.notifications.FCMProvider.isAvailable

    W/dalvikvm( 9093): VFY: unable to resolve static method 23769: Lcom/google/android/gms/common/GoogleApiAvailability;.getInstance ()Lcom/google/android/gms/common/GoogleApiAvailability;

    D/dalvikvm( 9093): VFY: replacing opcode 0x71 at 0x0001

    I/Unity ( 9093): UTNotifications Initialize: False

    From what I understand this means I've not included gms.common in my project, the trouble is, currently we're very close to the 65k limit, so we're having to juggle which play-services apis we include. I have tried including and building with play-services-base and play-services-basement however and it didn't help.

    Play services resolver didn't solve the issue.
     
  34. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @TheADrain ,

    65K limit is not such a big trouble, Unity can automatically split the Android app to 2 packages so 65K methods rule is respected (it works transparently for an end-user).

    So, it seems something is indeed wrong with Android libs. Could you please send us to the support email a list of all files and folders in Assets/Plugins/Android (including subfolders) so I'll check what libraries you're missing and tell you how to solve it.

    See also https://forum.unity3d.com/threads/too-many-method-references-max-is-65536.327064/

    Best regards,
    Yuriy, Universal Tools team.
     
  35. TheADrain

    TheADrain

    Joined:
    Nov 16, 2016
    Posts:
    48
    Hi Yuriy, thanks for the detailed response.

    We did fix the problem in the end, turns out that we had not included the play-services-iid library to be exported to android. So it's all working perfectly now.

    You mention that Unity can split the app into 2 packages? Could you elaborate on how to achieve this? As we've had a lot of trouble with the dex limit and have had to cut certain features from our game as a result. So if we could solve that, that would be great.

    Edit:

    Additionally, I'm having issues getting the Title and Message for Android notifications. They are being sent from Playfab so I can't be sure of the format but I don't believe Title or Message are under "data/" I think they are above that.

    Their format seems to be as follows, but I can't enter a value into the Advanced settings that doesn't start with "data/"

    {
    "Title": "Message from Game",
    "Icon": "open_chest",
    "Sound": "raw/open",
    "Message": "You've gained gold!",
    "CustomData": {
    "gold": "5",
    "currency": "G"
    }
    }
     
    Last edited: Mar 16, 2017
  36. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @TheADrain ,

    I'm glad that you sorted it out.

    Regarding splitting the app, we've never had to do it, so I can't give you an accurate information on that (but I heard it's possible from one of my ex-colleagues). Please see the Unity forum thread about that: https://forum.unity3d.com/threads/too-many-method-references-max-is-65536.327064/.

    Regarding the payload data format. In FCM, it's required to send any data in "data" section (except of "notification" messages, which are not supported by UTNotifications). So most likely, Playfab automatically wraps your data into the "data" node. So you can try using "data/Title" for a title and "data/Message" for a text, and "data/CustomData" as user data root. Please note, that "Icon" and "Sound" will be ignored anyway. You'll have to use notification profiles to specify icon and sound settings (see section "Using Notification Profiles (Sounds & Icons Settings)" of our manual.

    Best regards,
    Yuriy, Universal Tools team.
     
  37. TheADrain

    TheADrain

    Joined:
    Nov 16, 2016
    Posts:
    48
    Thanks for the response Yuriy,

    what is a 'notification' message? As our game only uses messages for notifications currently, we don't send any custom data. I've tried using 'data/Title' and 'data/Message' in the UTNotificationsSettings object but when sending a push to the device, the push says that it can't find them and that I could configure UTNotificationSettings.

    Does this mean I may not be able to use your plugin for sending simple push notifications?
     
  38. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi @TheADrain ,

    Please find details on "data" and "notification" FCM messages types here: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages. UTNotifications require using "data" messages to work correctly. Can you please find out what's the exact FCM message payload format is being sent to FCM server by Playfab in your case? Then I can tell you the values you need to specify in the UTNotifications messages format settings to handle those messages correctly.

    Best regards,
    Yuriy, Universal Tools team.
     
  39. InspiredSquare

    InspiredSquare

    Joined:
    Nov 16, 2015
    Posts:
    20
    Hi,
    We are unable to view multiline notification in Android.
    Regards,
    Zulqarnain
     
  40. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Zulqarnain,

    Could you please give me some more details so I can help you with that?
    1. What version of UTNotifications are you using? Is it the latest 1.6.2 or somewhat older?
    2. What notifications are experiencing troubles with? Local or push notifications? If local, how are scheduling them, what text are you specifying? If push, how does the message payload look like?
    3. Is it reproduced on a single specific Android device, or on any device? What version of Android are your test devices running?

    Looking forward to hearing back from you to help with it asap.

    Best regards,
    Yuriy, Universal Tools team.
     
    InspiredSquare likes this.
  41. TheADrain

    TheADrain

    Joined:
    Nov 16, 2016
    Posts:
    48
    Hi Yuriy,

    I'm not 100% sure what format the messages are being sent in, is there any way to debug the content of the message received?

    I think the format is

    { "Title": "Message from Game", "Icon": "open_chest", "Sound": "raw/open", "Message": "You've gained gold!", "CustomData": { "gold": "5", "currency": "G" } }

    as shown in PlayFab's documentation https://api.playfab.com/docs/tutorials/push-notifications-for-android
    but they also state that they use Amazon SNS to deliver pushes.

    Either way, I've tried
    data/Title
    data/Message
    data/Message/Title
    data/Message/Message
    data/title
    data/message

    and haven't been able to get it to work.

    Cheers
    Adrian
     
  42. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Adrian,

    The format you mentioned is not a valid FCM message payload - PlayFab must wrap it somehow. Please find more on FCM messages formats here. Please note, that UTNotifications support only "data" messages, so if PlayFab uses "notification" messages instead, it can be a reason of your troubles.
    Amazon SNS doesn't imply any specific messages format, it allows sending any messages payloads - so the messages format is defined by PlayFab. Please find out what they are sending to FCM servers (using SNS) in your case, so I can tell you how to configure UTNotifications to work with that format.

    Best regards,
    Yuriy, Universal Tools team.
     
  43. InspiredSquare

    InspiredSquare

    Joined:
    Nov 16, 2015
    Posts:
    20
    Hi Yuriy,
    1. We are using 1.6.2 version.
    2. We are sending push notifications from server not local.
    3. Yes we are facing this issue on multiple devices with different android version.

    Regards,
    Zulqarnain
     
    Last edited: Mar 29, 2017
  44. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Zulqarnain,

    Thanks for the details. Could you please show your FCM message payload, which is not displayed correctly?

    Best regards,
    Yuriy, Universal Tools team.
     
  45. InspiredSquare

    InspiredSquare

    Joined:
    Nov 16, 2015
    Posts:
    20
    Hi Yuriy,
    Thanks for the reply. Here is what server sending to client.
    {
    "data": {
    "badge_number": "1",
    "notification_profile": "knots",
    "id": "0",
    "text": "Welcome+push+notification+service%2C+testing+multiline+push+is+notification",
    "title": "Push+Notification+Service",
    "server_message": "na"
    },
    "to": "xxxXxxx_7j5WV827iVhZc50ni-FXpOd8b9Z_fn10OQp1pWuZne_Xxxxxxx"
    }

    Regards,
    Zulqarnain
     
    Last edited: Mar 30, 2017
  46. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Zulqarnain,

    The problem is how encode the text. This line is successfully broken into 2:
    "Welcome+push+notification+service%0Atesting+multiline+push+is+notification".

    Best regards,
    Yuriy, Universal Tools team.
     
    InspiredSquare likes this.
  47. InspiredSquare

    InspiredSquare

    Joined:
    Nov 16, 2015
    Posts:
    20
    Hi Yuriy,
    Thanks for the reply. Is there a way that i should not worry about new line character while sending text from server to android device just like iOS.

    Additionally i am sending push through demo server which is already encoded the text for android.

    Regards,
    Zulqarnain
     
  48. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Zulqarnain,

    In Android it's controlled by BigTextStyle of the notification. This style is always turned on by UTNotifications since the version 1.6.0. Unfortunately Android doesn't always show BigTextStyle notifications as multiline if they don't contain line break characters - f.e. if there are any other notifications it usually collapses BigTextStyle ones to a single-line mode to save screen space:

    Notifications in the notification drawer appear in two main visual styles, normal view and big view. The big view of a notification only appears when the notification is expanded. This happens when the notification is at the top of the drawer, or the user clicks the notification.

    The best option is to try reducing the text length you're displaying or to specify the line breaks manually.

    Best regards,
    Yuriy, Universal Tools team.
     
    InspiredSquare likes this.
  49. InspiredSquare

    InspiredSquare

    Joined:
    Nov 16, 2015
    Posts:
    20
    Hi Yuriy,
    Thanks for the explanation. I have successfully implemented multiline in android, a minor correction is required in Demo Server while preparing data,

    data.put("id", new Integer(id).toString()); -> data.put("id", new Integer(id));
    data.put("badge_number", new Integer(badge).toString()); -> data.put("badge_number", new Integer(badge));

    as receiver at client end is expecting integer values for badge_number and id.

    Otherwise i was receiving following exceptions when notification was received.

    W/Bundle: Key badge_number expected Integer but value was a java.lang.String. The default value -1 was returned.
    04-03 18:32:21.963 11376-12625/? W/Bundle: Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
    at android.os.BaseBundle.getInt(BaseBundle.java:801)
    at universal.tools.notifications.Manager.extractIntFromBundle(Manager.java:781)
    at universal.tools.notifications.Manager.postPushNotification(Manager.java:287)
    at universal.tools.notifications.GcmIntentService.onMessageReceived(GcmIntentService.java:11)
    at com.google.android.gms.gcm.GcmListenerService.zzo(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService.zzn(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService.zzm(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
    W/Bundle: Key id expected Integer but value was a java.lang.String. The default value -1 was returned.
    W/Bundle: Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
    at android.os.BaseBundle.getInt(BaseBundle.java:801)
    at universal.tools.notifications.Manager.extractIntFromBundle(Manager.java:781)
    at universal.tools.notifications.Manager.postPushNotification(Manager.java:288)
    at universal.tools.notifications.GcmIntentService.onMessageReceived(GcmIntentService.java:11)
    at com.google.android.gms.gcm.GcmListenerService.zzo(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService.zzn(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService.zzm(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
    at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)


    Regards,
    Zulqarnain


     
  50. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    488
    Hi Zulqarnain,

    In fact, both int and string arguments are supported (it's important as some servers are not able to send custom integer values). This is why we extract integer values from payload following way:

    Code (CSharp):
    1. value = bundle.getInt(key, defaultValue);
    2.  
    3. if (value == defaultValue) {
    4.     try {
    5.         String valueAsString = bundle.getString(key);
    6.         value = Integer.parseInt(valueAsString);
    7.     } catch (Throwable e) {}
    8. }
    So you may safely ignore the logcat messages, this case is handled absolutely correctly, both int and string values are supported as badge numbers.

    Best regards,
    Yuriy, Universal Tools team.
     
    InspiredSquare likes this.
unityunity