@wmora wmora released this Nov 1, 2017 · 31 commits to master since this release

Assets 2

Support for notification channels

Added support for notification channels for apps targeting Android Oreo (SDK 26) or higher. To learn more about them, go to the official documentation.

If you want to override the channel settings for Smooch notifications, set the following resource values to your own:

  • Smooch_settings_notificationChannelId: The channel ID
  • Smooch_settings_notificationChannelName: The channel name

If you do not use Smooch's ui library and you're targeting Android Oreo or higher and want to receive push notifications from Smooch, you'll need to register a BroadcastReceiver for action io.smooch.NOTIFICATION to your app's LocalBroadcastManager. This should be done in your Application class.

public class MyApplication extends Application {

    private static final String TAG = MyApplication.class.getName();

    public void onCreate() {
        super.onCreate();

        Settings settings = new Settings("your_app_id");
        Smooch.init(this, settings, null);

        LocalBroadcastManager.getInstance(this).registerReceiver(new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        if ("io.smooch.NOTIFICATION".equals(intent.getAction())) {
                            // Received a push notification from Smooch
                            Log.d(TAG, "Received push notification from Smooch");
                        }
                    }
                }, new IntentFilter("io.smooch.NOTIFICATION"));
    }

}