EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

Set Android Icon #113

Open kamranarshad opened 7 years ago

kamranarshad commented 7 years ago

Is there any way to set an icon for android. I only get a blank icon.

EddyVerbruggen commented 7 years ago

You mean when receiving a push notification? Not sure from the top of my head, but do you have all the icons in your app_resources folder?

kamranarshad commented 7 years ago

Yes, I do mean when receiving a push notification.

I do have the default icon in the app_resources/android folder.

EddyVerbruggen commented 7 years ago

Hmm, just tested on an Android 4.4 emulator with a freshly generated starter app and the icon shows up correctly in the tray as well as in the notification center (pull down from the top, the icon is bigger there).

Did you replace the default icon by a custom one which may have render issues?

kamranarshad commented 7 years ago

I am using the default icon provided when you run tns create appName

EddyVerbruggen commented 7 years ago

Me 2. What device is this, and what about others?

kamranarshad commented 7 years ago

I have only tested on my device Nexus 6P, I couldn't seem to get push notification working on android emulator, but will try again tomorrow.

EddyVerbruggen commented 7 years ago

Ok. I used a genymotion image with play services installed.

kamranarshad commented 7 years ago

I have play services installed in the include.gradle file and I have used a different icon, both don't seem to display an icon in the notification.

EddyVerbruggen commented 7 years ago

Let me try that again:

kamranarshad commented 7 years ago

I have tested on android emulator on android 6.0 and google play service pack.

EddyVerbruggen commented 7 years ago

So you've tested on the same Android version in Genymotion as I did, with the demo app and the default icons?

kamranarshad commented 7 years ago

I haven't tested on Genymotion, only on standard android emulator you get with android studio

EddyVerbruggen commented 7 years ago

OK so previously you said "I have only tested on my device Nexus 6P" - did you or did you not test on a real device? And if not please do so and check if the icon is OK..

kamranarshad commented 7 years ago

I have checked on real device and on standard android emulator but not Genymotion.

EddyVerbruggen commented 7 years ago

Ah OK, that took us 20 messages to figure out, lol 😄

Did you test those devices with the default {N} icons, or your own? In case of the latter: can I have them?

kamranarshad commented 7 years ago

I have tested with the default icon, I did use an icon from google images and that didn't seem to work to.

EddyVerbruggen commented 7 years ago

Are you building with the NativeScript CLI, or Telerik Platform?

EddyVerbruggen commented 7 years ago

It seems that the Android launcher icon is problematic as confirmed by the Firebase team in this issue.

kamranarshad commented 7 years ago

I am using the NativeScript CLI.

thomasmoon commented 7 years ago

Hello! The default icon from the assets folders worked for me with notifications in the Android status bar, but it seems like as of android 3.0, these require a specialized icon that is only white on a transparent background: https://stuff.mit.edu/afs/sipb/project/android/docs/guide/practices/ui_guidelines/icon_design_status_bar.html

This icon then gets put to a drawable folder for that specific platform version (ie. drawable-xhdpi-v11), but it should also be specified with its own name.

Here is some info on setting the notification specific icon on a Cordova Firebase plugin in the Android Manifest. Any idea how this could be done with this plugin? https://github.com/arnesson/cordova-plugin-firebase/issues/53

thomasmoon commented 7 years ago

So I was able to generate the simple icon one colour icon used in newer Android versions and then specify it in the message body. Is there a way to set a default icon through the plugin of Android manifest?

mn-martin commented 7 years ago

Anyone figured out yet how to provide these icons? (With or without help of the plugin) I'm struggling with this too.

mn-martin commented 7 years ago

This is actually described in the Google Firebase documentation. I think this ticket can be closed.

thomasmoon commented 7 years ago

Hey @mn-martin the simple one colour icons have to be added in the android drawable assets folder and then the icon to be displayed specified as part of the push notification payload, ie.:

curl -X POST --header "Authorization: key=<auth key>" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"notification\":{\"title\": \"My title\", \"text\": \"My text\", \"sound\": \"default\", \"badge\": \”1\", \"icon\": \"ic_stat_announcement\"}, \"data\":{\"messageId\": \"313967\"}, \"priority\": \"High\", \"to\": \”<firebase device token>\”}"

mn-martin commented 7 years ago

Thank you @thomasmoon this will be helpful if I need a special icon / message. Nice to have a resource for that issue now as well :-) 👍

Whip commented 5 years ago

I'm new to app development, can some summarize how to change default status bar icon of the app. I've created my white and transparent images and placed them in

app/App_Resources/Android/src/main/res/drawable-ldpi/status_icon.png
app/App_Resources/Android/src/main/res/drawable-mdpi/status_icon.png
app/App_Resources/Android/src/main/res/drawable-hdpi/status_icon.png
...

My app/App_Resources/Android/src/AndroidManifest.xml file looks like this

<manifest>
    <application>
        <service android:name="org.nativescript.plugins.firebase.MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
        <service android:name="org.nativescript.plugins.firebase.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/status_icon" />
    </application>
</manifest>

But its not working. What am I missing?

vytautas-pranskunas- commented 4 years ago

I cannot get it working - just get white square. I have read tt it might be due reason that icon does not fit requriements but i did generate icons using https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit Anybody solved that?

manojdcoder commented 4 years ago

The icon should be white in color with transparent background. Are you setting a custom color either from notification / in manifest?

vytautas-pranskunas- commented 4 years ago

No, that's the thing. Icon is white with transparent background and I do not v set custom color. Icon is exactly as in the link

manojdcoder commented 4 years ago

I'm pretty sure the plugin works, it does on my end. Hence you have already created a SO thread, I suggest we discuss there.

vytautas-pranskunas- commented 4 years ago

Maybe you can download that icon and check if it works with that icon?

vytautas-pranskunas- commented 4 years ago

I have made simple icon just put there white dot and it worked. My guess is that the should not be any transparent dots on icon just white 100% opacity or none? Because icon generator made aliasing does to make icon more smooth?

If yes - how to generate nice icon from logo?

manojdcoder commented 4 years ago

I generally turn the logo into white and background to transparent, it worked almost every time. You may share the icon if you still have the issue.

vytautas-pranskunas- commented 4 years ago

Yes i still have an issue.

ic_stat_logo_sign_white.zip

sure here is my icon

vytautas-pranskunas- commented 4 years ago

@manojdcoder have you had a chance to look / try the icon?

vytautas-pranskunas- commented 4 years ago

It started to work after i removed android folder undel platforms and rebuild whole solution