Search Unity

Easy Cross-Platform Notifications available now!

Discussion in 'Assets and Asset Store' started by CarlosFM, Jun 8, 2013.

  1. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    $Screen Shot 2013-06-10 at 11.01.48.png

    Hi all!

    I am very excited to announce that my first Asset submission has been approved and it is available to everyone to download:

    http://u3d.as/content/carlos-fernandez-musoles/easy-cross-platform-notifications

    Remote notifications in mobile platforms can be a little scary to implement because of all the little details you need to get right to make it work (permissions, certificates, server code and database, client code...)

    With Easy Cross-Platform Notifications (ECPN) you will get all the server-side and client side code, a full 'how to' guide and a Unity scene example to get you started!

    The guide will explain what needs to be done on your project in order to get a truly platform-agnostinc notification service to send messages easily between iOS and android, all sitting comfortably within a Unity application.

    What can you potentially do with Remote Notifications (with the help of ECPN)?
    - Send a message to all your app users
    - Let users invite their friends to your app if they are not around
    - Send reminders to users -even let them set it themselves!
    - Possibilities are endless! Messages are received irrespective of whether the user is running your app at the moment or not, so you could even set your own messaging service :p



    If you do try it and have any comments, please let me know! For support and suggestions, post here or send me an email to:

    carlos.fernandez.musoles (at) gmail.com

    Thank you and happy coding!

    Updated: Here are some screenshots showing what this package can accomplish.

    1) Unity example scene used to register/unregister current device and to send messages to other devices.
    $Screenshot_2013-06-09-15-37-04.png

    2) iPhone 4 receiving the push notification sent from the Unity scene
    $photo.PNG

    3) Samsung Galaxy SII (android) receiving the same notification (via Google Cloud Message service)
    $Screenshot_2013-06-09-15-43-01.png
     

    Attached Files:

    Last edited: Dec 12, 2013
  2. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    You can also post comments and find all my published work (for the future!) on my blog
     
  3. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    So this is a complete package for push notigications for ios and android?
     
  4. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    It contains everything you need to set up Remote notifications in both iOS and Android. So yes, it is a complete package :)

    It should be noted that it's not a "drag and drop" only solution, due to the nature of notifications in both platforms -permissions and certificates need to be set up, as well as the need of a server running PHP and a MySQL database.

    But fear not! The package comes with all the code you will need, a full step-by-step guide on how to set everything up, as well as a demo scene to show how the notifications can be used. It also comes with my full support, should you struggle at any point :p

    Go ahead and give it a try!

    Cheers,
    Carlos.
     
  5. Burletech

    Burletech

    Joined:
    Jul 1, 2010
    Posts:
    73
    Pretty excited about this. I was planning on having to roll out my own system and really wasn't wanting to hassle with it.

    Not to the phase of needing this yet but you can definitely expect a purchase from me when I am.
     
  6. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @Burletech: Good to hear! That's what this package is all about: making the implementation of Remote Notifications as painless as possible :p
     
  7. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    do u have apk demo? Very interesting if you have it working.
     
  8. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Sure! I'm sending you a demo on a PM :)
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Hi, I'm very interested in this product. However all I want to do is set a push notification to show up after 2 hours, from code in the game itself, when it's not focused. I just want to notify the user when their "energy" has refilled. I don't understand why the heck a PHP or a database would be needed for this use case. Is it? I don't need to broadcast messages to all players or anything like that.
     
  10. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @jerotas: perhaps you wouldn't need remote notifications but local notifications. My package was designed with remote notifications in mind, and that's why you need a server to store user IDs and send requests to Apple / Google to broadcast a message to multiple users.

    You could use it for local notifications as well, registering your own device and instead of sending a message to all, just send to self. It all depends on your user case; from what I read in your post, you want your user to know when he has got their energy back -am I to assume this happens when the user is not using your app, right? If that is the case, who knows when your user gets its energy at 100%? If it is you -your server- then you could use ECPN to notify users periodically when this happens; but if it is like a set period of time -say 2 hours after last execution- then a local notification would be the way to go, as remote notifications are a tad more complicated for this case.

    EDIT: After reading your post in another thread, I believe you want a timer set up within the app which will fire the notifications to the user. For local notifications you could use the following:
    - Android: a Service started every time your app quits, running with a timer which will fire a local notifications. You need to write your own java plugin for this.
    - iOS: I am pretty sure you can use the NotificationServices class to set and receive local notifications in iOS devices.
     
    Last edited: Jun 11, 2013
  11. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    demo works great, purchasing.
     
  12. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @imtrobin: glad to hear! Please let me know what you think, and of course contact me if you have any issues.
     
  13. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Hi Carlos

    Can you please

    1. I see for apple, you are sending device uuid. Isn't that disallowed?
    http://www.macrumors.com/2013/03/21...nique-device-identifier-udid-beginning-may-1/

    2. Something of a wish, most of the time. the client does not send the notification but rather the server. If you can make so it tracks the app since last launch, and server can send a notification (we can customize) that would be great.
     
  14. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Hi imtrobin,

    Not really, push notifications make use of the device Token, which is different from the UDID -so you are safe!
    reference

    I'm not sure what you are asking here; notifications are ALWAYS sent by your server, on request from the user. The way it works is: the user requests its device to be registered -- Apple / Google send the device token to the user -- the user sends the token to your server -- the server stores it for future references; then, when the user wants to send a message to anyone (or someone) it sends a request to your server -- your server collates all information (i.e. device tokens) and sends the final request to Apple / Google -- Apple / Google sends directly a notification to the list of devices.

    Sorry if I misunderstood.

    EDIT: For question number 1, if you are talking about the example scene using the Unity ID -which may be the UDID for iOS devices, I don't know- don't worry, this is only an arbitrary identifier. In your projects, you can substitute this for ANY other unique identifier you may come up to differentiate users from each other. In a game I'm working on, I use their username instead.

    Notification messages are independent from what you use as identifier, this only serves the purpose of matching a device Token and a user; in other words, if one user wants to send a message to a particular friend, he will only know the identifier [for example 'John01'], so he will send a request to your server like 'send a message to John01']; your server will then look in its tables for John01's device Token and will use the latter to send the notification. This is designed that way because users should not need to know other devices' Tokens.

    Cheers.
     
  15. m.otsu

    m.otsu

    Joined:
    Nov 19, 2012
    Posts:
    2
    Hi Carlos

    It is an error if you include the android.jar when compiling Unity
    compile passes When you delete a android.jar.
    android.jar may be deleted?
     
  16. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @m.otsu: you are absolutely right, this is my fault! I forgot to mention it in the instructions -version control fail!

    The android.jar serves no purpose at all in unity, the only time you may need it is when you are trying to recompile the GCMJava.jar project -if you are interested in implementing further the android plugin (see section in the manual about recompiling the plugin).

    You can safely remove it, or better yet, move it outside your project assets folder -the compilation error will dissapear.

    Thanks!
     
  17. m.otsu

    m.otsu

    Joined:
    Nov 19, 2012
    Posts:
    2
    Carlos Thank you for answers.
     
  18. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I'm talking about a cron job which sends periodic notifications to inform users about things to do etc, a little spammy. Most use case of notifications is seldom initiated from user to user, right?
     
  19. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Gotcha now.

    Yes, remote notifications are well suited for user-to-user and server-to-user communications. If you want something local to remind your users to get back to your app, or other kind of messages app-to-user, you will be better equipped with local notifications. I am currently finishing up an asset to set timed local notifications, so your app can send messages to the user -even with time delay (whether they are using the app or not).

    Fingers crossed, it will get to the Asset Store very soon!
     
  20. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Just keeping everyone posted: I have submitted a new package that helps developers to use local notifications on android projects! Pretty much an android version of NotificationServices class :)

    As per ECPN, I am finishing an update and will be uploading it soon -nothing dramatic, just polishing the Guide and a couple of things.

    Cheers.
     
  21. ASubtitledDeath

    ASubtitledDeath

    Joined:
    Sep 18, 2012
    Posts:
    2
    Hey Carlos,

    I am lovin your plugin - I just got the iOS part up and running and it's great.

    I am having a little problem with the Android side though. I am following the guide to recompile the the JAVA library but I can't find the classes.jar file in the package - I think you may have forgot to include it in your latest update.

    Let me know if I am missing something here.

    Thanks.
     
  22. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Oh, I must have!

    Anyways, the class.jar is included (or should be!) for convenience only, as everyone has it in its computer. You can simply search on your computer for classes.jar, or here is some guidance on Mac.

    Here is the official Unity information to find the jar file, under the "Expanding the UnityPlayerActivity Java Code" section.

    Apologies for the confusion!

    Cheers
     
  23. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Easy Cross Platform Notifications 1.01 Update is available now!

    The wait is over. The new update is ready in the Asset Store.

    Release notes:

    - AndroidManifest.xml changes:
    o Android:name=”StaticApplicationContext” no longer required
    o Removed incompatibility with new devices: android:targetSdkVersion=”16” removed at the bottom

    - Changes to the guide:
    o Added warning about android dx compilation error and how to solve it

    - Changes to ECPNManager.cs:
    o Added code to gather application context from unity activity


    Please note: if you are upgrading from the previous version, both the androidmanifest.xml file and the ECPNManager.cs have been modified, so if you had altered them you may loose your information. Please back them up before upgrading to prevent any data loss.
     
  24. hrjunker

    hrjunker

    Joined:
    Nov 15, 2011
    Posts:
    26
    Hi Carlos

    This looks like excacly the solution I need for my projects, but just a minor question. Is it possible to have custom notification icons? if not is it something you plan on implementing in the future?
     
  25. Crazy Robot

    Crazy Robot

    Joined:
    Apr 18, 2009
    Posts:
    921
    Hey,

    So with this system, I don't need a 3rd party to send out the notifications like Urban Airship?
     
  26. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @hrlarsen: you can add your own custom icon easily, just substitute the icon that comes with the package with your own, no problems!

    @Crazy Robot: indeed, this is a stand alone package. With it you won't be dependent on any other third party system such as Urban airship to send your notifications (since you will have your own server!).
     
  27. hrjunker

    hrjunker

    Joined:
    Nov 15, 2011
    Posts:
    26
    Sounds good Carlos.

    An additional question: Do you know if it is possible to have the Database as a MSSQL? Because I have the app using an MSSQL as it is now, and it would be nice to have it all in one place :)
     
  28. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    It is possible, but you may have to tweak the current php scripts as they use mysql commands to get and set data to the DB. It shouldn't be too hard, here is a list of mssql commands available in php.
     
  29. hrjunker

    hrjunker

    Joined:
    Nov 15, 2011
    Posts:
    26
    Thanks for your answer Carlos, just bought the plugin. I will post the php code for MSSQL when I am done, so you could maybe include it in the plugin for others to benefit from :)
     
  30. n1var

    n1var

    Joined:
    Mar 15, 2013
    Posts:
    5
    Hey,

    I imported asset, loaded sample scene and found some bugs.
    While android app is receiving registration id, screen becomes black (about 1 sec).
    After registration id is received, screen returns to my scene view.
    How to fix this black screen bug?
     
  31. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @n1var: Yes, I am aware of this. The bug has been fixed and is now in the Asset Store approval queue -they are taking an unusual long time to process it.
     
  32. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    748
    What does the backend interface look like for sending push notifications?
     
  33. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    748
    Any plans to support windows phone / blackberry?
     
  34. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Hi trooper,

    The backend is written in java -for the interaction with android and the Google Cloud Messages API- and PHP for the server code. It's all pretty straightforward and easy to extend, and all the code is included with the package.

    As per your second point, I don't have immediate plans to port it to windows phone or blackberry, but it may be something I will consider in the future!
     
  35. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    748
    How do you send push notifications? Is it via a web interface like pushwoosh etc or do we have to write our own?
     
  36. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    You don't need to write anything extra! It's all coordinated from within your Unity project. From registering devices (both iOS and android) to sending push messages, it's all done with c#.

    For more sophisticated behaviour you may need to extend either the PHP scripts or the MySQL database -the server code is the one that ultimately sends the notification requests to Google and Apple servers. But for basic registering and sending messages, you are all set ;P
     
  37. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Hi all,

    Finally version 1.04 got approved and is available to everyone! This version includes several fixes, the most important being the flashing black screen when calling certain functions on android platform. The guide has been updated here and there (see "Version Control") to comment some of the common pitfalls and errors.
     
  38. n1var

    n1var

    Joined:
    Mar 15, 2013
    Posts:
    5
    On IOS when app is runing push notifications do not appear.
     
  39. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @n1var: this is NOT a defect, it is how is supposed to be. Users don't need a notification when they are already in the app :)

    If you want to respond to the notification and show something to the user, you can use the unity NotificationServices class to deal with it.
     
  40. skrad

    skrad

    Joined:
    Jul 18, 2012
    Posts:
    17
    Hello Carlos, is your plugin works with unity 3.5.5? and is your plugin will work with other plugins or do i have to rebuild the jar files, to make it work.

    Thanks.
     
  41. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    The plugin certainly works in Unity 3.5.5 -as a matter of fact I fully developed it on Unity 3.5.7, so it should have no problems with any 3.x

    As per the other plugins, it should work fine, as long as you add the appropriate activities / permissions to the androidmanifest. Inevitably, though, you will have to recompile the java classes, since the package name should match your app name -this is fully explained in the guide, and all you need is included in the package (you would need a java compiler -I use Dr Java and Eclipse to do it). You won't need to touch any other plugin, so you are safe.

    I am always available for support, should you need any help.

    Cheers.
     
  42. n1var

    n1var

    Joined:
    Mar 15, 2013
    Posts:
    5
    Hi again,

    I need to send metadata (some variables from server) on ios?
    How can I do that?
     
  43. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Hi n1var,

    I'm not sure I understand what you are trying to achieve. Please send me a note to my email address with the details and I'll see how to help you best.

    carlos.fernandez.musoles (at) gmail.com

    Cheers.
     
  44. n1var

    n1var

    Joined:
    Mar 15, 2013
    Posts:
    5
    hi, i sent you an email. pls check out and reply. ;)
     
  45. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    @n1var: I've seen it, thanks :) I sent you an email with my reply
     
  46. KyleOlsen

    KyleOlsen

    Joined:
    Apr 3, 2012
    Posts:
    237
    Hey Carlos,

    I'm having an issue using Dr Java that you recommended in the follow through documentation. You mention "To import the java files in Dr. Java just open them with the newly created project! You should see the project structure:"

    GCMJava
    - Source Files
    -- com
    --- your
    ---- app
    ------1
    ------2
    ------3...

    But after opening all 4 files I get the following file structure and an invalid .jar file as a result:

    GCMJava
    - External Source Files
    --1
    --2
    --3...

    Any idea what I'm doing wrong?
     
    Last edited: Sep 19, 2013
  47. KyleOlsen

    KyleOlsen

    Joined:
    Apr 3, 2012
    Posts:
    237
    Update to previous post-

    I opened the supplied drjava file and reassigned everything inside of your provided project, compiled, built the jar and everything looks good now.
     
  48. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    Hi KyleOlsen,

    When you are recompiling the GCMJava project, you should first rearrange the folder structure to match your package name, then import them to your Dr Java project and don't forget to change the "package" clause name on each .java file before recompiling.
     
  49. teophilik

    teophilik

    Joined:
    Feb 13, 2013
    Posts:
    11
    Hey, I have just implemented the plugin in my app but the notification title that appears on my device remains "ECPN" even after I modified the line in GCMIntentService.java. Is there anything more I have to do to make it work?

    And another question: Is there any way I can change what happens when I tap on the notification?

    Thanks!
     
  50. CarlosFM

    CarlosFM

    Joined:
    Jun 8, 2013
    Posts:
    240
    After changing the value of NOTIFICATION_TITLE in GCMIntentService.java you must recompile the GCMJava.jar and put it on the Assets>Plugins>Android folder -so basically substituting the GCMJava.jar to make sure the app is using the updated one

    As per changing what happens when your users tap on the notification, take a look at the method "generateNotification(context,message)" within the GCMIntentService.java class. When the plugin is creating a notification, it is passing an Intent (i.e. what will happen when the notification is tapped). By default this is just opening your app, but you can change it to whatever you like, or nothing at all! ;P