najvaflutter 1.1.7

najvaflutter #

Flutter plugin for implementing NajvaSDK in your flutter application without interaction with java code.

Implementation guide #

Here is simple way to implement najva-flutter-plugin to your flutter application

Add plugin #

First you need to add najvaFlutter to your project. in order tt add plugin to your project open pubspecs.yaml file and add this line as dependency

  najvaflutter: ^1.1.6

open najvaFlutter page in to get latest version

then run commend bellow to update your flutter project packages

$ flutter pub get

Changes in your code #

Create a class named Najva or any name you think is good and extent from NajvaFlutter.

class Najva extends NajvaFlutter {

NajvaFlutter has three methods called init , initUserHandling and initJSONNotification.

By calling init method and passing the right argument your NajvaSDK will be initialized and your push notification will work correctly.


CHAMPAIGN_ID is your champaignId that you can create or find in your panel.

WEBSITE_ID is your websiteId that can be found in your panel.

API_KEY is your api key that can be found in your panel.

LOCATION_ENABLED is a boolean. if set true the NajvaSDK will improve your push notifications by users location and also Location permission will be asked from user if android version is above 6.0.

By calling initUserHandling the plugin will get user token and passed it to a method called onUserSubscribed. Simply by overriding this method you can send the token to your server or do whatever you want.


  void onUserSubscribed(String token) {

By calling initJSONNotification the plugin will not handle incomming notifications and passes the data to method called onNewJSONDataReceived. Simply by overriding this method you can handle incomming data and implement your own code.


  void onNewJSONDataReceived(String jsonData) {

Not using the plugin code #

If you want to not use this plugin and handle anything in java code you can remove this plugin and in your android dependencies add the code bellow.

implementation 'com.najva.sdk:najva-android-sdk:1.0.6'

Or you can keep the plugin in your flutter project.

Removing Najva service #

In order to disable Najva service from your android manifest and handle get notifications in your service first add the following to your app manifest file

    tools:node="remove" />

The code above will remove our service from your android manifest file.

Then add the following code to your manifest file to declare a new service

<service android:name=".MyFcmService">
        <action android:name="" />
  • Note that all changes in AndroidManifest.xml file must be under <application> tag.

Then create a class called MyFcmService. your class must look like this:

public class MyFcmService extends FirebaseMessagingService {


The FirebaseMessagingService has to methods called onMessageReceived and onNewToken. You can Override them and in order to use Najva call NajvaPushNotificationHandler.handleMessage and NajvaPushNotificationHandler.handleNewToken in these methods.

public void onMessageReceived(RemoteMessage remoteMessage) {
    NajvaPushNotificationHandler.handleMessage(getApplicationContext(), remoteMessage);

public void onNewToken(String s) {
    NajvaPushNotificationHandler.handleNewToken(getApplicationContext(), s);

Or if you use another push notification service you can simply call their methods there.

1.0.0 #

  • functionality for najvaSDK

1.0.1 #

  • fix bugs

1.0.2 #

  • najva sdk updated

1.0.3 #

  • License updated
  • example README file changed

1.0.4 #

  • navjaSDK updated to the latest version

1.1.1 #

  • najvaSDK updated to the 1.1.1 version

1.1.4 #

  • najvaSdk updated to the 1.1.4 version

1.1.5 #

  • firebase initialization bug fix
  • bug fix

1.1.6 #

  • najvaSDK updated to the 1.1.5 version

1.1.7 #

  • fix gradle problem
  • fix user subscribed method was private


Example main.dart #

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  void initState() {
    new NajvaFlutter().init(CHAMPAIGN_ID,WEBSITE_ID,API_KEY,LOCATION_ENABLED); // you must add this line to your project 
    // and in some cases save it to a variable field.
    // also its better to create a class and extend from NajvaFlutter and use that instead.

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  najvaflutter: ^1.1.7

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:najvaflutter/najvaflutter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Sep 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/najvaflutter.dart. (-0.50 points)

Analysis of lib/najvaflutter.dart reported 1 hint:

line 25 col 3: This function has a return type of 'Future', but doesn't end with a return statement.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies