Coder Social home page Coder Social logo

Comments (6)

Ben834 avatar Ben834 commented on May 19, 2024 2

Hi,

If your app is just in the background, onNewIntent would be called.

If your app is not running at all, the intent is normally passed through the onCreate, where you should handle it. Can you check this ?

Ben.

from quickstart-android.

dezmaeth avatar dezmaeth commented on May 19, 2024 1

Im having the same problem , the intent doesnt hold any data, both on onCreateand onNewIntent

from quickstart-android.

sajedul-karim avatar sajedul-karim commented on May 19, 2024 1

I am implementing FCM(Firebase messaging Service) in my application. Here all seems ok except when app is in background state i am not able to extract expected notification data.

here is concepts: There are two types of messages in FCM:

display-messages: These messages only work when your app is in foreground.

data-messages: Theses messages work even if your app is in background When our app is in the background, Android directs notification messages to the system tray.

for handling data-messages your notification should have click_action = "YOUR_ACTION" field.

My message will like this:

{
"data": {
"body": "here is body",
"title": "Title",
"click_action": "YOUR_ACTION"
},
"to": "ffEseX6vwcM:APA91bF8m7wOF MY FCM ID 07j1aPUb"
}
The Activity will display the message that menifest file will like this:

        <intent-filter>
            <action android:name="YOUR_ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

After clicking on Notification it will redirect to my NotificationActivity . In my NotificationActivity in onCreate and onNewIntent method i am extracting message using this way:

Bundle bundle=getIntent().getExtras();
if(bundle!=null) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d("DATA_SENT", String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
Unfortunately in my NotificationActivity i am getting bellow message:

google.sent_time: 1471631793774

from: 50711789666

google.message_id 0:1471631793776823%098e508d098e508d

collapse_key: com.myapp.package_name

But where is my expected notification data?

Here is my system configuration:

Android Studio Version: 2.1.3

Firebase Version: com.google.firebase:firebase-auth:9.0.1

Google Play service version : com.google.android.gms:play-services:9.2.1

from quickstart-android.

samtstern avatar samtstern commented on May 19, 2024

@hungud I believe @Ben834 has offered the correct solution here so I will close this issue. Please re-open if checking in onCreate does not work for you.

from quickstart-android.

sajedul-karim avatar sajedul-karim commented on May 19, 2024

Unfortunately in my NotificationActivity i am getting bellow message:

google.sent_time: 1471631793774

from: 50711789666

google.message_id 0:1471631793776823%098e508d098e508d

collapse_key: com.myapp.package_name

from quickstart-android.

sajedul-karim avatar sajedul-karim commented on May 19, 2024

finally, i solved my problem. Please visit this answer
Firebase Notification Problem

from quickstart-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.