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

add channel #699

Merged
merged 13 commits into from
Jun 13, 2018
Merged

add channel #699

merged 13 commits into from
Jun 13, 2018

Conversation

evollu
Copy link
Owner

@evollu evollu commented Dec 20, 2017

the app crashes because of
compile "com.android.support:support-core-utils:26.1.0"

@evollu evollu mentioned this pull request Dec 20, 2017
@Titozzz
Copy link
Contributor

Titozzz commented Feb 5, 2018

Please merge this ! I need it and it's working fine for me !

@Titozzz
Copy link
Contributor

Titozzz commented Feb 5, 2018

By the way i tested this on Android 8 and Android 7.1 (and iOS in case of breaking), and local notification are working <3

@evollu
Copy link
Owner Author

evollu commented Feb 5, 2018

@Titozzz you can target this branch in your npm.
yarn add react-native-fcm@git://github.com/evollu/react-native-fcm#sdk-26

@evollu
Copy link
Owner Author

evollu commented Feb 5, 2018

There are 2 reasons why the PR is not merged.

  1. as I mentioned in Android 8 Support #698, I can't get my sample project to compile.
  2. facebook hasn't officially support compiling with SDK 26. merging this into main branch will force everyone to upgrade to an non-officially supported state.

@sahil290791
Copy link

I am still not getting any notification icon when the app is in background, but the app is getting the data in registerKilledListeners as per the example. Any idea how can I get the icon in the notification shade? I am using sdk-26 branch of react-native-fcm.

compileSdkVersion 26
buildToolsVersion '26.0.2'
targetSdkVersion 26

@evollu
Copy link
Owner Author

evollu commented May 3, 2018

I am still not getting any notification icon when the app is in background? is banner not showing up?

@sahil290791
Copy link

@evollu, yes its banner(notification icon) is not showing up but the app receives the notification payload. This is happening in devices running on android 8+, before I had upgraded the SDK to 26 everything was working as it is.

Do I need to do any additional setup for 8.0 devices?

@sahil290791
Copy link

sahil290791 commented May 4, 2018

@evollu I have created a notification channel by referring this: https://github.com/invertase/react-native-firebase-docs/blob/master/docs/notifications/android-channels.md

Now I can see the notification channel listed in settings > apps > my-app > notifications. But still I am unable to see the notification icon in the notification tray/shade.

@sahil290791
Copy link

@evollu its finally working, needed to send channel key inside custom_notification:

"data" : {
 	"show_in_foreground": true,
 	"content_available" : true,
 	"priority" : "high",
	 "title" : "Sample title",
	 "message": "Sample message",
	 "type": "DEEPLINK",
	 "sound": "default",
	 "vibrate": 300,
         "lights":  true,
          "utm_medium": "medium",
	  "utm_campaign": "campaign",
	  "utm_content": "content",
	  "utm_term": "term",
	  "utm_source": "example",
	  "channel": "default",
	 "custom_notification" : {
	   "body" : "Sample body",
	   "color": "#F58024",
	   "title" : "Sample title",
	   "type": "DEEPLINK",
            "sound": "default",
	   "icon": "ic_notif",
	   "channel": "default",
	   "picture": "image_url"
	 },
 },

Added channel creation in registerListeners:

export function registerAppListener(openPushNotification, handleOpenURL) {
  const channel = new firebase.notifications.Android.Channel('default',
  'Notification', firebase.notifications.Android.Importance.Max)
  .setDescription('Receive notifications');

  // channel id is set as: default
  // Create the channel
  firebase.notifications().android.createChannel(channel);
}

The channel id in the notification payload should match the one given while channel creation.

@cylim
Copy link

cylim commented May 19, 2018

@sahil290791

According to the example of the changes, your registerAppListener can be replaced with

FCM.createNotificationChannel({
      id: 'default',
      name: 'Default',
      description: 'general usage',
      priority: 'high'
})

@evollu evollu merged commit cb2c6cc into master Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants