Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

issue remote notification with 3rd party service like onesignal , parse , kii

Discussion in 'Scripting' started by tong2528, Jun 1, 2015.

  1. tong2528

    tong2528

    Joined:
    Oct 9, 2014
    Posts:
    4
    I have a some issue user didn’t click the remote notification and go to the application by click on the icon app did 3rd party. do you have anything that handle this case so the message in remote notification it can't get

    for more detail about this issue look at this link

    https://www.dropbox.com/s/f4prmdydfodbspr/issue remote noti.pdf?dl=0
     
  2. JKasten

    JKasten

    Joined:
    Apr 11, 2013
    Posts:
    23
    Hello,

    iOS does not have a built in way to get notifications that have not been opened. However there are 2 options that can be done to work around the problem. (Instructions details apply using push notifications with OneSignal) :

    1. You can always send your notifications with content_available set to true. This will wake up your app in the background with the data that was received. However to get this data you will need to create Objective-C code implementing the application:didReceiveRemoteNotification:fetchCompletionHandler: selector and store the message. Then when the user opens your app you will need to call into Objective-C again to check for any saved massages.
    2. You can use our create notification REST API from your own server and store the message you sent in your own database too. Then when your app is opened you can make a call to your server to check for any pending notifications.

    Here are some more details if your looking into implementing option 1.
    1. Add the application:didReceiveRemoteNotification:fetchCompletionHandler: selector to OneSignalUnityRuntime.m.
    2. Swizzle (by calling injectSelector) on this new selector. You can follow how didFinishLaunchingWithOptions is added in the code.
    3. In application:didReceiveRemoteNotification:fetchCompletionHandler: save the apns userInfo to the device.
    4. Add a new _savedNotifications function to read the data saved from step 3 as pass it back to a Unity method. Maybe call it SavedNotificationsRetrieved.
    5. Add a new SavedNotifications method to OneSignalIOS.cs and OneSignal.cs that calls into _savedNotifications.
    6. Add the SavedNotificationsRetrieved method to OneSignal.cs and any code you wan to process the saved notifications.

    For Android there is a Background Data option. You can save the intent.getBundleExtra("data") value and then load it when the users comes back to your app.

    Thanks.
     
  3. tong2528

    tong2528

    Joined:
    Oct 9, 2014
    Posts:
    4
    hello thanks for the answer actually I'm getting stuck in android and I 'm already chat with onesignal team and they advice me to use the a Background Data option. but I try and it not work like they said right now I'm already send the android eclipse pj and unity pj to onesignal team to clarify these issue hope they will fix it soon but I would like to find another 3rd party that already implement these function in their sdk
     
  4. JKasten

    JKasten

    Joined:
    Apr 11, 2013
    Posts:
    23
    Hey Tong, I was the one helping you through our chat support and glad you got it working with Android now. We may add a feature to our SDK to retrieve unopened notifications in a future update but we don't have a release date.

    Just in case anyone else implements the above don't forget you still need the GCM receiver documented on Step 3.2B of our setup guide in addition to the background receiver in your AndroidManifest.xml.
     
  5. tong2528

    tong2528

    Joined:
    Oct 9, 2014
    Posts:
    4
    hello JKasten

    thanks for help me out there I will stick with onesignal forever