• Resolved Wilbur

    (@ozu)


    I am buiding an Android app fro client.s blog with push notifications functionlity. For some unknown reason reason, the Android library just refuses to work. I keep seeing

    09-28 02:19:07.206 1096-1096/com.makuse.carsfeature V/AsyncHttpRH: Progress 238 from 196 (121%)

    I thought I followed the instructions on Push Notifications library for Android | Delite Studio explicitly.

    This is how I set it up don’t know where I got it wrong.

    @Override
        protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);
    
            Bundle extras = intent.getExtras();
            String id = extras.getString(PushNotifications.ID);
    
            Intent lIntent = new Intent(this, MainActivity.class);
            lIntent.putExtra("NotifId", id);
            this.startActivity(lIntent);
            finish();
        }
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Log.d(TAG, "onCreate");
    
            final PushNotifications pushNotifications = new PushNotifications(this, getString(R.string.push_key), getString(R.string.push_secret));
            if (pushNotifications.getToken() == null || pushNotifications.isExpired()) {
                Log.d(TAG, "Token is null or has expired");
                pushNotifications.refreshToken("https://example.com/pnfw/register/", getString(R.string.project_num));
            } else {
                Log.d(TAG, "Token is not null or expired");
            }
            //Get link from external apps
            Intent extIntent = getIntent();
            Uri extURL = extIntent.getData();
            String extLink = String.valueOf(extURL);
    
            if (extURL != null) {
                Log.d(TAG, "I got the external postlink,it is " + extLink);
                Intent intent = new Intent(this, MainActivity.class);
                intent.putExtra("extLink", extLink);
                this.startActivity(intent);
                finish();
            } else {
                Log.d(TAG, "No external link");
                Bundle bundle = getIntent().getExtras();
                if (bundle != null) {
                    Log.d(TAG, "It has notification url");
                    String id = bundle.getString(PushNotifications.ID);
                    Intent intent = new Intent(this, MainActivity.class);
                    intent.putExtra("NotifId", id);
                    this.startActivity(intent);
                    finish();
                } else {
                    Log.d(TAG, "No notification url");
                    Intent intent = new Intent(this, MainActivity.class);
                    startActivity(intent);
                    finish();
                    overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
                }
            }
    
        }
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Delite Studio

    (@delitestudio)

    What you are seeing is a normal log from the connection library, it’s not an error.
    Please make sure R.string.push_key, R.string.push_secret point to the correct values (from the OAuth section), that "https://example.com/pnfw/register/" points to your real server and that R.string.project_num is the correct project number on Google API Console.
    Otherwise if something is not correctly set it will not work.

    Thread Starter Wilbur

    (@ozu)

    Thanks for the reply. I will verify the values and get back to you guys.

    Thread Starter Wilbur

    (@ozu)

    I have verified that all the values are correct but I keep seeing the line “Token is null or has expired” in logcat and I haven’t gotten any notification.

    Plugin Author Delite Studio

    (@delitestudio)

    Do you see any debug log on the WordPress side?
    Do you see any token on the WordPress side?
    Please also make sure your AndroidManifest.xml is correct with all requested permissions.

    Thread Starter Wilbur

    (@ozu)

    I see this in debug:

    Finished Fire OS notifications	
    October 3, 2016 8:22 PM
    Do not send Fire OS notifications	
    October 3, 2016 8:22 PM
    Processing new chunk from offset 0	
    October 3, 2016 8:22 PM
    Starting Fire OS notifications	
    October 3, 2016 8:22 PM
    Finished Android notifications	
    October 3, 2016 8:22 PM
    Processing new subpage with 0 tokens	
    October 3, 2016 8:22 PM
    Processing new chunk from offset 0	
    October 3, 2016 8:22 PM
    Starting Android notifications	
    October 3, 2016 8:22 PM

    I didn’t see any token.

    • This reply was modified 8 years, 1 month ago by Wilbur.
    Plugin Author Delite Studio

    (@delitestudio)

    So in the Tokens page you see zero tokens?
    You may have problems on the Android side, double check your AndroidManifest.xml is correct, and please copy it here (we suppose permission problems or misconfiguration).

    Thread Starter Wilbur

    (@ozu)

    Yes I see no tokens.
    I have checked and seem not to find the problem. This is my manifest file:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="https://schemas.android.com/apk/res/android"
              package="com.wilbur.blogger">
    
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    
        <uses-permission android:name="android.permission.GET_ACCOUNTS" />
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    
        <permission android:name="com.wilbur.blogger.permission.C2D_MESSAGE"
                    android:protectionLevel="signature"/>
        <uses-permission android:name="com.wilbur.blogger.permission.C2D_MESSAGE" />
    
        <application
            android:name=".activities.GApplication"
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <receiver
                android:name=".receivers.MyReceiver"
                android:enabled="true">
            </receiver>
    
            <receiver
                android:name="com.delitestudio.pushnotifications.PushNotifications$MessageReceiver"
                android:permission="com.google.android.c2dm.permission.SEND" >
                <intent-filter>
                    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                    <category android:name="com.wilbur.blogger" />
                </intent-filter>
            </receiver>
    
            <activity
                android:name=".activities.SplashActivity"
                android:theme="@style/SplashTheme">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
    
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
            <activity...//removed the activities
        </application>
    
    </manifest>
    Plugin Author Delite Studio

    (@delitestudio)

    It seems to be correct. If you try this curl command:

    curl https://YOUR_SITE/pnfw/register/ --data "os=Android&token=YOUR_TOKEN"

    do you have any success?

    If yes your Push Notifications for WordPress (Lite) installation is working.

    Thread Starter Wilbur

    (@ozu)

    Please which token will I pass for “YOUR_TOKEN” ? Or better still is there any way I could test using PostMan?

    • This reply was modified 8 years, 1 month ago by Wilbur.
    Plugin Author Delite Studio

    (@delitestudio)

    First of all you must disable OAuth to be able to send commands with curl, then you can use any string you want, we will only test that the registration API works.

    If it works, we can exclude problems on the WordPress side and focus on Android/Google. Please make sure you have:

    • a real device
    • Google Play installed with a logged in user
    • a correct setup for GCM notifications

    Then I suggest you to give me a complete logcat of one session of your app.

    Thread Starter Wilbur

    (@ozu)

    I used volley to make the request thus:

    private void testNoti() {
            Log.d(TAG, "testNoti called.....");
            //Using http returns error 301 so I used https
            StringRequest postRequest = new StringRequest(Request.Method.POST,"https://MY_SITE_URL/pnfw/register/",
                    new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                   Log.d(TAG, response);
                }
            },
                    new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError volleyError) {
                            Log.d(TAG, volleyError.toString());
                            Log.d(TAG, "onErrorResponse called");
    
                        }
                    }){
    
                @Override
                protected Map<String, String> getParams() throws AuthFailureError {
                    Map<String,String> params= new HashMap<>();
                    params.put("os","Android");
                    params.put("token","mytoken");
                    return params;
    
                }
            };
    
            RetryPolicy policy = new DefaultRetryPolicy(5000, 2, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
            postRequest.setRetryPolicy(policy);
            postRequest.setShouldCache(false);
            RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
            requestQueue.add(postRequest);
        }

    It gave this 200 Ok result:

    <html>
        <head>
            <link rel='canonical' href='https://MY_SITE_URL/pnfw/register/' />
            <script data-cfasync="false" type="text/javascript">window.google_analytics_uacct = "UA-68565532-11";</script>
            <script data-cfasync="false" type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['e._setAccount', 'UA-66555532-11']);
    _gaq.push(['f._setAccount', 'UA-38339005-1']);
    _gaq.push(['e._setDomainName', 'MY_SITE_URL']);
    _gaq.push(['f._setDomainName', 'MY_SITE_URL']);
    _gaq.push(['e._setCustomVar',1,'template','pub_site_noads',3]);
    _gaq.push(['e._setCustomVar',2,'t','147',3]);
    _gaq.push(['e._setCustomVar',3,'rid','0',2]);
    _gaq.push(['e._setCustomVar',4,'bra','mod2',3]);
    _gaq.push(['e._setAllowAnchor',true]);
    _gaq.push(['e._setSiteSpeedSampleRate', 10]);
    _gaq.push(['f._setCustomVar',1,'template','pub_site_noads',3]);
    _gaq.push(['f._setCustomVar',2,'domain','MY_SITE_URL',3]);
    _gaq.push(['f._setSiteSpeedSampleRate', 20]);
    _gaq.push(['e._trackPageview']);
    _gaq.push(['f._trackPageview']);
    
    _gaq.push(['_setAccount', 'UA-12184421-5']);
    _gaq.push(['_setDomainName', 'MY_SITE_URL']);
    _gaq.push(['_trackPageview']);
    
    (function() {
     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js';
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
    
    var ez_tos_track_count = 0;
    var ez_last_activity_count = 0;
    (function (__ez_tos) {
      window.setInterval(function () {
        __ez_tos = (function (t) {
          return t[0] == 45 ? (parseInt(t[1]) + 1) + ':00' : (t[1] || '0') + ':' + (parseInt(t[0]) + 15);
        })(__ez_tos.split(':').reverse());
    
        ez_tos_track_count++;
        if(ez_tos_track_count > 1 && ez_tos_track_count < (ez_last_activity_count + 4) && ez_tos_track_count < 240)
        {
            if(window.pageTracker)
            {
                pageTracker._trackEvent('Time', 'Log', __ez_tos);
    			new EzoicAnalytics().storeImpression();
            }
            else
            {
               _gaq.push(['e._trackEvent', 'Time', 'Log', __ez_tos]);
               _gaq.push(['f._trackEvent', 'Time', 'Log', __ez_tos]);
    		   new EzoicAnalytics().storeImpression();
            }
    
    		if(typeof(_paq) != 'undefined')
            {
                _paq.push(['trackEvent', 'Time', __ez_tos, 'TimeOnPage']);
            }
    
        }
      }, 15000);
    })('00');
    
            </script>
            <script type="text/javascript">var ezouid = "929718742";</script>
            <base href="https://MY_SITE_URL/pnfw/register/">
            <!--[if lt IE 9]>
            <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
            <![endif]-->
            <!--[if (gte IE 9) | (!IE)]>
            <!-->
            <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
            <!--
            <![endif]-->
            <script type='text/javascript'>
    var ezoTemplate = 'pub_site_noads';
    if(typeof ezouid == 'undefined')
    {
        var ezouid = 'none';
    }
    var ezoFormfactor = '1';
    var ezo_elements_to_check = Array();
    </script>
            <script>
    var old_jquery = null;
    var old_jquery_sign = null;
    function open_jquery_wrapper()
    {
        if(typeof $ezJQuery != 'undefined')
        {
            old_jquery = jQuery;
            old_jquery_sign = $;
            $ = $ezJQuery;
            jQuery = $ezJQuery;
        }
    }
    function close_jquery_wrapper()
    {
        if(typeof $ezJQuery != 'undefined')
        {
            $ = old_jquery_sign;
            jQuery = old_jquery;
        }
    }
    </script>
            <!-- START EZHEAD -->
            <script type='text/javascript'>
    var soc_app_id = '0';
    var did = 7676;
    var ezdomain = 'MY_SITE_URL';
    var ezoicSearchable = 1;
    </script>
            <!---->
            <!-- END EZHEAD -->
            <script src="//MY_SITE_URL/utilcave_com/templates/js/ezjquery-noconflict.js"></script>
            <script data-cfasync="false" data-pagespeed-no-defer type='text/javascript'>
    function ez_isclean( data ) {
        if (typeof data === 'undefined') { data = document.URL; }
        var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))(@|%2540|%40)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
        var isClean = !re.test(data);
        return isClean;
    }
    
    var ez_queue = new Array();
    function sort_queue(a, b)
    {
      if( a.priority < b.priority ) return -1;
      else if( a.priority == b.priority ) return 0;
      else return 1;
    }
    function execute_ez_queue()
    {
      ez_queue.sort( sort_queue );
    
      for( var i in ez_queue )
      {
            if(typeof ez_queue[i].method != "undefined")
            {
                try{
                    ez_queue[i].method.call( null );
                }
                catch (err) {
    
                }
            }
      }
    }
    
    var ez_ad_units = new Array();
    var ezslots = new Array();
    function ez_write_tag(d) {
        if(ez_isclean() && d instanceof Array) {
    
    		ez_ad_units[ez_ad_units.length] = d;
            var ezcmd = "googletag.cmd.push(function() {var divid = 'div-gpt-ad-"+d[1]+"-0';if(typeof ezlrarn == 'function'){ezlrarn(divid);}googletag.display(divid);});";
    		return ezcmd;
        }
        else {
            return "1+1";
        }
    }
    function in_array(needle, haystack) {
        var length = haystack.length;
        for(var i = 0; i < length; i++) {
            if(haystack[i] == needle) return true;
        }
        return false;
    }
    
            </script>
            <script data-cfasync='false' data-pagespeed-no-defer >var ezrpos = new Array();var ez_current_interval;var ez_current_load = 0;</script>
            <style>.ezoic-floating-bottom { display: none!important; }.ezoic-ad{display:inline-block;}</style>
            <style>.adtester-container-127 {display:none;}
    .adtester-container-124 {display:none;}
    .adtester-container-109 {display:none;}
    .adtester-container-119 {display:none;}
    .adtester-container-126 {display:none;}
    .adtester-container-115 {display:none;}
    .adtester-container-121 {display:none;}
    .adtester-container-118 {display:none;}
    .adtester-container-103 {display:none;}
    .adtester-container-110 {display:none;}
    .adtester-container-100 {display:none;}
    .adtester-container-122 {display:none;}
    .adtester-container-101 {display:none;}
    .adtester-container-108 {display:none;}
    .adtester-container-116 {display:none;}
    .adtester-container-107 {display:none;}
    .adtester-container-113 {display:none;}
    .adtester-container-111 {display:none;}
    .adtester-container-123 {display:none;}
    .adtester-container-120 {display:none;}
    .adtester-container-117 {display:none;}
    .adtester-container-106 {display:none;}
    .adtester-container-114 {display:none;}
    .adtester-container-125 {display:none;}
    .adtester-container-102 {display:none;}
    .adtester-container-104 {display:none;}
    .adtester-container-112 {display:none;}
    .adtester-container-105 {display:none;}
    </style>
            <script type="text/javascript" cf-async="false">var _ezaq = {"ab_test_id":"mod2","ab_test_val":"","ad_location_ids":"","adgroup_rank_id":-1,"adx_ad_count":0,"country":"US","device_height":528,"device_width":1280,"domain_id":7676,"forensiq_score":-1,"form_factor_id":1,"has_bad_words":0,"ip":"10.0.2.45","landing_page_url":"https://www.MY_SITE_URL/pnfw/register/","max_ads":4,"page_ad_positions":"","page_view_count":0,"page_view_id":"def5f284-07c9-4bb3-6298-cd32d1cdcbe3","pv_event_count":0,"referrer_id":0,"region":"eu-west-1","serverid":"52.211.65.6:29449","sub_page_ad_positions":"","t_epoch":1475652030,"template_id":147,"url":"https://MY_SITE_URL/pnfw/register/","user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36","user_id":929718742,"visit_id":1299827616,"visit_uuid":"fa262828-7fba-40f9-7669-974e1079f741","word_count":0};var _ezim_d = {};var _ezat = {"domain_id":7676,"form_factor_id":1,"pageview_date":"2016-10-05","pageview_id":"def5f284-07c9-4bb3-6298-cd32d1cdcbe3","template_id":147,"url":"https://MY_SITE_URL/pnfw/register/","visit_uuid":"fa262828-7fba-40f9-7669-974e1079f741"};</script>
            <script data-cfasync='false' type="text/javascript" src="/ezoic/imp2.js?cb=137-7&v=1"></script>
            <script data-pagespeed-no-defer data-cfasync='false' type="text/javascript" src="/ezoic/banger.js?cb=137-7&bv=2&v=16&PageSpeed=off"></script>
        </head>
        <body>
            <script data-cfasync="false" type="text/javascript">
    
    if (typeof $ezJQuery == 'undefined') {
        if (typeof jQuery == 'undefined') {
            document.write('
                <scr'+'ipt type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js">
                </sc'+'ript>');
        } else {
            $ezJQuery = jQuery;
        }
    }
    
    if (typeof $ezJQuery == 'undefined' && typeof jQuery != 'undefined') {
        $ezJQuery = jQuery.noConflict(true);
    }
    
    if (typeof $ezJQuery != 'undefined') {
        $ezJQuery("body").mousemove(function(e){
          ez_last_activity_count = ez_tos_track_count;
        });
        $ezJQuery("body").keypress(function(e){
          ez_last_activity_count = ez_tos_track_count;
        });
        $ezJQuery(window).scroll(function(e){
          ez_last_activity_count = ez_tos_track_count;
        });
    } else {
        ez_last_activity_count = 8;
    }
            </script>
            <script type="text/javascript">
    var __ez_dims = (function() {
    	var setCookie = function( name, content, expiry ) {
    		return document.cookie = name+'='+content+((expiry)?';expires='+(new Date(Math.floor(new Date().getTime()+expiry*1000)).toUTCString()):'');
    	};
    	var ffid = 1;
    	var oh = window.screen.height;
    	var ow = window.screen.width;
    	var h = ffid === 1 ? oh : (oh > ow) ? oh : ow;
    	var w = ffid === 1 ? ow : (oh > ow) ? ow : oh;
    	var uh = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;
    	var uw = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
    	setCookie('ezds', encodeURIComponent('ffid='+ffid+',w='+w+',h='+h), (31536e3*7));
    	setCookie('ezohw', encodeURIComponent('w='+uw+',h='+uh), (31536e3*7));
    })();
    </script>
            <script type='text/javascript' src='//MY_SITE_URL/utilcave_com/inc/tb.php?cb=137-7&shcb=5&template=orig'></script>
            <script>
    $ezJQuery(function() {
        if (typeof run_body_onload == 'function') {
            run_body_onload();
        }
        if (typeof ezoicJSPageLoad == 'function') {
            ezoicJSPageLoad($ezJQuery);
        }
    });
    </script>
        </body>
    </html>
    <!--[ezpicker:done]-->

    And I can now see tokens from the dashboard. What next?

    Plugin Author Delite Studio

    (@delitestudio)

    It’s strange. The 200 OK response message must be empty, here we see an HTML as a response.

    Please contact us from our direct contact form as we need to take a look to the real site.

    Thread Starter Wilbur

    (@ozu)

    Ok. I just contacted you guys.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘It just refuses to get a token’ is closed to new replies.