Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Push: Open application Activity after the click on the notification #20

Open
michalblaha opened this issue Sep 27, 2015 · 17 comments
Assignees

Comments

@michalblaha
Copy link

Rendy, is any way how to set an Activity which is called after the click on the notification?
Or open the main Activity of the app?
Or do you plan to add it to the code? (for ex. like here: https://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/android/local_notifications_in_android_walkthrough/ )

@rdelrosario
Copy link
Owner

Right now it loads the activity in launch mode. Yes i am planning to add some code so that you can setup which activity to load, just haven't had the time to figure out the best way to do this.

@rdelrosario rdelrosario self-assigned this Oct 1, 2015
@jmeadecvlt
Copy link
Contributor

this is really important, any update on this request?

@jmeadecvlt
Copy link
Contributor

can you review the pull request I submitted? I've tested this locally and it works as expected for us.

@JohnMcAvinue
Copy link

Has this been implemented now? I get the notification to the device and IPushNotificationListener.OnMessage fires with the correct payload.

I'm fairly new to Android so wondering if there's some boilerplate I can hack to respond to notifications being clicked, and directing the user to a custom Notification activity

@CR4567
Copy link

CR4567 commented May 20, 2016

+1
Any progress on this?

@jmeadecvlt
Copy link
Contributor

Rendy updated the code a while back that allows the android payload to be accessed, @CR4567: did you grab latest and try it out?

@CR4567
Copy link

CR4567 commented May 20, 2016

thanx for the quick answer.
I'm on version 1.1.7, this should be the recent one, right?
Accessing the payload when the message arrives isn't a problem. But I'm trying to handle messages differently after clicking and opening the app. Did I miss this in the documentation? I couldn't find a method that is called after clicking the msg.

@jmeadecvlt
Copy link
Contributor

apologies, I should have been more specific, yes, the library lets you access the payload once the notification was clicked. The notification should/will fire OnCreate if your app isn't running. In that method, check Intent.Extras. If extras isn't null, there should be a KeySet collection that has the values you can use to handle any downstream decisions about what to load. hth

@CR4567
Copy link

CR4567 commented May 20, 2016

hm.... weird... you're absolutely right, the onCreate fires when clicking the msg and there is also an Intent.Extras with isEmpty = false.... but I still can't find the values of the notification.

@jmeadecvlt
Copy link
Contributor

inside OnCreate:

Bundle extras = Intent.Extras;

if (extras != null) {

    //YAY, we have message details
    foreach (var key in extras.KeySet()) {
        System.Diagnostics.Debug.WriteLine(string.Format("MainActivity::Notification::Key:{0}|Value:{1}", key, extras.Get(key)));
    }

}

@CR4567
Copy link

CR4567 commented May 21, 2016

Ah nice. that's working. Thx a lot... couldn't see the content in debug mode but seems to be a debug problem.

@CR4567
Copy link

CR4567 commented Nov 17, 2016

after all that time, thinking everything is fine, I found some new and weir behavior... I mixed this code with #39 to receive and react on push notifications even when app is closed.
After debugging several times, for me, it looks like the onCreate method is called each time you click on a push. Makes sense and is working usually.... but after I closed the app and clicked the notification it looks like the onCreate is only used once ... when I'm clicking again on a new push only the app starts but without any further processing....

Does that make sense to anyone? Is it using a different service or thread after closing the app?

@fazil1979
Copy link

Is there any update?

@corte
Copy link

corte commented Mar 6, 2017

Any updates on this? I really need this feature :(

@JulianPasque
Copy link

I also need this feature.

@DECWebSites
Copy link

Any update?

I need to open a specific screen when I click the notification on Android.

Is it already possible?

@EmmanVazz
Copy link

I am on version 1.2.4. You can access the message with the method @jmeadecvlt mentioned, I use this inside OnCreate in MainActivity.cs

if(!string.IsNullOrEmpty(Intent.GetStringExtra("message")))
{
   //app was started via a push notification
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants