Push notification on count.ly












0















Below is the code snippet which is demo application listed in countly documentation for sending push notifications to user in android & we have community edition of countly , issue is users are not even getting registered in countly.



Demo provided by countly



After adding necessary credentials in above demo app none of those is actually registering my device in countly , is countly accurate to show live users ? or am i missing anything wrong in below code ?



public class MainActivity extends Activity {

private BroadcastReceiver messageReceiver;

/**
* You should use try.count.ly instead of YOUR_SERVER for the line below if you are using Countly trial service
*/
final String COUNTLY_SERVER_URL = "http://xxxx";
final String COUNTLY_APP_KEY = "xxxx";
final String COUNTLY_MESSAGING_PROJECT_ID = "xxxx";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Context appC = getApplicationContext();
Countly.onCreate(this);
Countly.sharedInstance().setLoggingEnabled(true);
Countly.sharedInstance().setPushIntentAddMetadata(true);
Countly.sharedInstance().enableCrashReporting();
Countly.sharedInstance().setViewTracking(true);
Countly.sharedInstance().setAutoTrackingUseShortName(true);
Countly.sharedInstance().setRequiresConsent(false);
Countly.sharedInstance().setConsent(new String{Countly.CountlyFeatureNames.sessions}, true);
Countly.sharedInstance().init(appC, COUNTLY_SERVER_URL, COUNTLY_APP_KEY)
.initMessaging(this, MainActivity.class, COUNTLY_MESSAGING_PROJECT_ID, Countly.CountlyMessagingMode.PRODUCTION);

Countly.sharedInstance().recordEvent("test", 1);

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Countly.sharedInstance().recordEvent("test2", 1, 2);
}
}, 5000);

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Countly.sharedInstance().recordEvent("test3");
}
}, 10000);
}

@Override
public void onStart() {
super.onStart();
Countly.sharedInstance().onStart(this);
}

@Override
public void onStop() {
Countly.sharedInstance().onStop();
super.onStop();
}

@Override
protected void onResume() {
super.onResume();

// Register for broadcast action if you need to be notified when Countly message received
messageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Message message = intent.getParcelableExtra(CountlyMessaging.BROADCAST_RECEIVER_ACTION_MESSAGE);
Log.i("CountlyActivity", "Got a message with data: " + message.getData());

//Badge related things
Bundle data = message.getData();
String badgeString = data.getString("badge");
try {
if (badgeString != null) {
int badgeCount = Integer.parseInt(badgeString);

boolean succeeded = ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
if (!succeeded) {
Toast.makeText(getApplicationContext(), "Unable to put badge", Toast.LENGTH_SHORT).show();
}
}
} catch (NumberFormatException exception) {
Toast.makeText(getApplicationContext(), "Unable to parse given badge number", Toast.LENGTH_SHORT).show();
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(CountlyMessaging.getBroadcastAction(getApplicationContext()));
registerReceiver(messageReceiver, filter);
}

@Override
protected void onPause() {
super.onPause();
unregisterReceiver(messageReceiver);
}
}









share|improve this question





























    0















    Below is the code snippet which is demo application listed in countly documentation for sending push notifications to user in android & we have community edition of countly , issue is users are not even getting registered in countly.



    Demo provided by countly



    After adding necessary credentials in above demo app none of those is actually registering my device in countly , is countly accurate to show live users ? or am i missing anything wrong in below code ?



    public class MainActivity extends Activity {

    private BroadcastReceiver messageReceiver;

    /**
    * You should use try.count.ly instead of YOUR_SERVER for the line below if you are using Countly trial service
    */
    final String COUNTLY_SERVER_URL = "http://xxxx";
    final String COUNTLY_APP_KEY = "xxxx";
    final String COUNTLY_MESSAGING_PROJECT_ID = "xxxx";

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Context appC = getApplicationContext();
    Countly.onCreate(this);
    Countly.sharedInstance().setLoggingEnabled(true);
    Countly.sharedInstance().setPushIntentAddMetadata(true);
    Countly.sharedInstance().enableCrashReporting();
    Countly.sharedInstance().setViewTracking(true);
    Countly.sharedInstance().setAutoTrackingUseShortName(true);
    Countly.sharedInstance().setRequiresConsent(false);
    Countly.sharedInstance().setConsent(new String{Countly.CountlyFeatureNames.sessions}, true);
    Countly.sharedInstance().init(appC, COUNTLY_SERVER_URL, COUNTLY_APP_KEY)
    .initMessaging(this, MainActivity.class, COUNTLY_MESSAGING_PROJECT_ID, Countly.CountlyMessagingMode.PRODUCTION);

    Countly.sharedInstance().recordEvent("test", 1);

    new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
    Countly.sharedInstance().recordEvent("test2", 1, 2);
    }
    }, 5000);

    new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
    Countly.sharedInstance().recordEvent("test3");
    }
    }, 10000);
    }

    @Override
    public void onStart() {
    super.onStart();
    Countly.sharedInstance().onStart(this);
    }

    @Override
    public void onStop() {
    Countly.sharedInstance().onStop();
    super.onStop();
    }

    @Override
    protected void onResume() {
    super.onResume();

    // Register for broadcast action if you need to be notified when Countly message received
    messageReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
    Message message = intent.getParcelableExtra(CountlyMessaging.BROADCAST_RECEIVER_ACTION_MESSAGE);
    Log.i("CountlyActivity", "Got a message with data: " + message.getData());

    //Badge related things
    Bundle data = message.getData();
    String badgeString = data.getString("badge");
    try {
    if (badgeString != null) {
    int badgeCount = Integer.parseInt(badgeString);

    boolean succeeded = ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
    if (!succeeded) {
    Toast.makeText(getApplicationContext(), "Unable to put badge", Toast.LENGTH_SHORT).show();
    }
    }
    } catch (NumberFormatException exception) {
    Toast.makeText(getApplicationContext(), "Unable to parse given badge number", Toast.LENGTH_SHORT).show();
    }
    }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(CountlyMessaging.getBroadcastAction(getApplicationContext()));
    registerReceiver(messageReceiver, filter);
    }

    @Override
    protected void onPause() {
    super.onPause();
    unregisterReceiver(messageReceiver);
    }
    }









    share|improve this question



























      0












      0








      0








      Below is the code snippet which is demo application listed in countly documentation for sending push notifications to user in android & we have community edition of countly , issue is users are not even getting registered in countly.



      Demo provided by countly



      After adding necessary credentials in above demo app none of those is actually registering my device in countly , is countly accurate to show live users ? or am i missing anything wrong in below code ?



      public class MainActivity extends Activity {

      private BroadcastReceiver messageReceiver;

      /**
      * You should use try.count.ly instead of YOUR_SERVER for the line below if you are using Countly trial service
      */
      final String COUNTLY_SERVER_URL = "http://xxxx";
      final String COUNTLY_APP_KEY = "xxxx";
      final String COUNTLY_MESSAGING_PROJECT_ID = "xxxx";

      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Context appC = getApplicationContext();
      Countly.onCreate(this);
      Countly.sharedInstance().setLoggingEnabled(true);
      Countly.sharedInstance().setPushIntentAddMetadata(true);
      Countly.sharedInstance().enableCrashReporting();
      Countly.sharedInstance().setViewTracking(true);
      Countly.sharedInstance().setAutoTrackingUseShortName(true);
      Countly.sharedInstance().setRequiresConsent(false);
      Countly.sharedInstance().setConsent(new String{Countly.CountlyFeatureNames.sessions}, true);
      Countly.sharedInstance().init(appC, COUNTLY_SERVER_URL, COUNTLY_APP_KEY)
      .initMessaging(this, MainActivity.class, COUNTLY_MESSAGING_PROJECT_ID, Countly.CountlyMessagingMode.PRODUCTION);

      Countly.sharedInstance().recordEvent("test", 1);

      new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
      Countly.sharedInstance().recordEvent("test2", 1, 2);
      }
      }, 5000);

      new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
      Countly.sharedInstance().recordEvent("test3");
      }
      }, 10000);
      }

      @Override
      public void onStart() {
      super.onStart();
      Countly.sharedInstance().onStart(this);
      }

      @Override
      public void onStop() {
      Countly.sharedInstance().onStop();
      super.onStop();
      }

      @Override
      protected void onResume() {
      super.onResume();

      // Register for broadcast action if you need to be notified when Countly message received
      messageReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
      Message message = intent.getParcelableExtra(CountlyMessaging.BROADCAST_RECEIVER_ACTION_MESSAGE);
      Log.i("CountlyActivity", "Got a message with data: " + message.getData());

      //Badge related things
      Bundle data = message.getData();
      String badgeString = data.getString("badge");
      try {
      if (badgeString != null) {
      int badgeCount = Integer.parseInt(badgeString);

      boolean succeeded = ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
      if (!succeeded) {
      Toast.makeText(getApplicationContext(), "Unable to put badge", Toast.LENGTH_SHORT).show();
      }
      }
      } catch (NumberFormatException exception) {
      Toast.makeText(getApplicationContext(), "Unable to parse given badge number", Toast.LENGTH_SHORT).show();
      }
      }
      };
      IntentFilter filter = new IntentFilter();
      filter.addAction(CountlyMessaging.getBroadcastAction(getApplicationContext()));
      registerReceiver(messageReceiver, filter);
      }

      @Override
      protected void onPause() {
      super.onPause();
      unregisterReceiver(messageReceiver);
      }
      }









      share|improve this question
















      Below is the code snippet which is demo application listed in countly documentation for sending push notifications to user in android & we have community edition of countly , issue is users are not even getting registered in countly.



      Demo provided by countly



      After adding necessary credentials in above demo app none of those is actually registering my device in countly , is countly accurate to show live users ? or am i missing anything wrong in below code ?



      public class MainActivity extends Activity {

      private BroadcastReceiver messageReceiver;

      /**
      * You should use try.count.ly instead of YOUR_SERVER for the line below if you are using Countly trial service
      */
      final String COUNTLY_SERVER_URL = "http://xxxx";
      final String COUNTLY_APP_KEY = "xxxx";
      final String COUNTLY_MESSAGING_PROJECT_ID = "xxxx";

      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Context appC = getApplicationContext();
      Countly.onCreate(this);
      Countly.sharedInstance().setLoggingEnabled(true);
      Countly.sharedInstance().setPushIntentAddMetadata(true);
      Countly.sharedInstance().enableCrashReporting();
      Countly.sharedInstance().setViewTracking(true);
      Countly.sharedInstance().setAutoTrackingUseShortName(true);
      Countly.sharedInstance().setRequiresConsent(false);
      Countly.sharedInstance().setConsent(new String{Countly.CountlyFeatureNames.sessions}, true);
      Countly.sharedInstance().init(appC, COUNTLY_SERVER_URL, COUNTLY_APP_KEY)
      .initMessaging(this, MainActivity.class, COUNTLY_MESSAGING_PROJECT_ID, Countly.CountlyMessagingMode.PRODUCTION);

      Countly.sharedInstance().recordEvent("test", 1);

      new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
      Countly.sharedInstance().recordEvent("test2", 1, 2);
      }
      }, 5000);

      new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
      Countly.sharedInstance().recordEvent("test3");
      }
      }, 10000);
      }

      @Override
      public void onStart() {
      super.onStart();
      Countly.sharedInstance().onStart(this);
      }

      @Override
      public void onStop() {
      Countly.sharedInstance().onStop();
      super.onStop();
      }

      @Override
      protected void onResume() {
      super.onResume();

      // Register for broadcast action if you need to be notified when Countly message received
      messageReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
      Message message = intent.getParcelableExtra(CountlyMessaging.BROADCAST_RECEIVER_ACTION_MESSAGE);
      Log.i("CountlyActivity", "Got a message with data: " + message.getData());

      //Badge related things
      Bundle data = message.getData();
      String badgeString = data.getString("badge");
      try {
      if (badgeString != null) {
      int badgeCount = Integer.parseInt(badgeString);

      boolean succeeded = ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
      if (!succeeded) {
      Toast.makeText(getApplicationContext(), "Unable to put badge", Toast.LENGTH_SHORT).show();
      }
      }
      } catch (NumberFormatException exception) {
      Toast.makeText(getApplicationContext(), "Unable to parse given badge number", Toast.LENGTH_SHORT).show();
      }
      }
      };
      IntentFilter filter = new IntentFilter();
      filter.addAction(CountlyMessaging.getBroadcastAction(getApplicationContext()));
      registerReceiver(messageReceiver, filter);
      }

      @Override
      protected void onPause() {
      super.onPause();
      unregisterReceiver(messageReceiver);
      }
      }






      android countly-analytics






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 8 at 2:14









      erkanyildiz

      10.5k64167




      10.5k64167










      asked Jan 1 at 7:53









      KOTIOSKOTIOS

      9,19822853




      9,19822853
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Since you don't see your user on Countly dashboard, it's one of the following:




          • Wrong COUNTLY_APP_KEY;

          • Wrong COUNTLY_SERVER_URL;

          • Some connectivity issue - your device cannot access that server.


          You've enabled logging by Countly.sharedInstance().setLoggingEnabled(true), so your Logcat should have some errors which would tell you which one of those is about your case.



          Also you use sdk-messaging dependency instead of sdk-messaging-fcm. First one uses GCM, which is deprecated in favor of FCM, that is Firebase. We have a detailed guide for that.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993885%2fpush-notification-on-count-ly%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Since you don't see your user on Countly dashboard, it's one of the following:




            • Wrong COUNTLY_APP_KEY;

            • Wrong COUNTLY_SERVER_URL;

            • Some connectivity issue - your device cannot access that server.


            You've enabled logging by Countly.sharedInstance().setLoggingEnabled(true), so your Logcat should have some errors which would tell you which one of those is about your case.



            Also you use sdk-messaging dependency instead of sdk-messaging-fcm. First one uses GCM, which is deprecated in favor of FCM, that is Firebase. We have a detailed guide for that.






            share|improve this answer




























              0














              Since you don't see your user on Countly dashboard, it's one of the following:




              • Wrong COUNTLY_APP_KEY;

              • Wrong COUNTLY_SERVER_URL;

              • Some connectivity issue - your device cannot access that server.


              You've enabled logging by Countly.sharedInstance().setLoggingEnabled(true), so your Logcat should have some errors which would tell you which one of those is about your case.



              Also you use sdk-messaging dependency instead of sdk-messaging-fcm. First one uses GCM, which is deprecated in favor of FCM, that is Firebase. We have a detailed guide for that.






              share|improve this answer


























                0












                0








                0







                Since you don't see your user on Countly dashboard, it's one of the following:




                • Wrong COUNTLY_APP_KEY;

                • Wrong COUNTLY_SERVER_URL;

                • Some connectivity issue - your device cannot access that server.


                You've enabled logging by Countly.sharedInstance().setLoggingEnabled(true), so your Logcat should have some errors which would tell you which one of those is about your case.



                Also you use sdk-messaging dependency instead of sdk-messaging-fcm. First one uses GCM, which is deprecated in favor of FCM, that is Firebase. We have a detailed guide for that.






                share|improve this answer













                Since you don't see your user on Countly dashboard, it's one of the following:




                • Wrong COUNTLY_APP_KEY;

                • Wrong COUNTLY_SERVER_URL;

                • Some connectivity issue - your device cannot access that server.


                You've enabled logging by Countly.sharedInstance().setLoggingEnabled(true), so your Logcat should have some errors which would tell you which one of those is about your case.



                Also you use sdk-messaging dependency instead of sdk-messaging-fcm. First one uses GCM, which is deprecated in favor of FCM, that is Firebase. We have a detailed guide for that.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 7 at 15:42









                ArtemArtem

                18217




                18217
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993885%2fpush-notification-on-count-ly%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas