android push notification

0 votes

hi, i tried to setup push notifications in my android app. i follwed the tutorial and set it up. i dont know how much ive done right. ill be adding snippets of by code below. the ussr gets added to the push notification users in the app42 hq push options but when i click on send push from the hq the device doesnt recieve the notifications.

 

im explaining in short what i have done, i downloaded the push notification example available on github. made the package com.shephertz.app42.push.plugin in my app. copy pasted all the classes from the sample app to mine.

 

the following code is a part of my homeactivity which is launched after the user loggs in

import com.shephertz.app42.paas.sdk.android.App42API;
import com.shephertz.app42.paas.sdk.android.App42Log;
import com.shephertz.app42.push.plugin.App42GCMController;
import com.shephertz.app42.push.plugin.App42GCMController.App42GCMListener;
import com.shephertz.app42.push.plugin.App42GCMService;

import com.shephertz.app42.paas.sdk.android.App42API;

public class HomeActivity extends AppCompatActivity implements App42GCMListener{

    private static final String GoogleProjectNo = "my projct no<editied for privacy>";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        App42API.setLoggedInUser(App42API.getLoggedInUser());
        App42Log.setDebug(true);
    }

    public void onStart() {
        super.onStart();
        if (App42GCMController.isPlayServiceAvailable(this)) {
            App42GCMController.getRegistrationId(HomeActivity.this,
                    GoogleProjectNo, this);
        } else {
            Log.i("App42PushNotification",
                    "No valid Google Play Services APK found.");
        }
    }


    @Override
    public void onError(String errorMsg) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onGCMRegistrationId(String gcmRegId) {
        // TODO Auto-generated method stub
        App42GCMController.storeRegistrationId(this, gcmRegId);
        if(!App42GCMController.isApp42Registerd(HomeActivity.this))
            App42GCMController.registerOnApp42(App42API.getLoggedInUser(), gcmRegId, this);
    }

    @Override
    public void onApp42Response(final String responseMessage) {
        // TODO Auto-generated method stub
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
            }
        });
    }

    @Override
    public void onRegisterApp42(final String responseMessage) {
        // TODO Auto-generated method stub
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                App42GCMController.storeApp42Success(HomeActivity.this);
            }
        });
    }

    final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String message = intent
                    .getStringExtra(App42GCMService.ExtraMessage);
        }
    };


}

 

please solve this for me asap. 

thanks

asked Apr 29, 2016 in Android by checker.kshitij (10 points)

1 Answer

0 votes

HI Checker,

Greetings!!!

As User is successfully registered on AppHQ, everything that you have done is fine. But there may be a case some configuration missing in AndroidManifest.xml file.

You need to mdifify the same as per steps mentioned in ReadME file.

  1. Need to add App42GCMService.java in service section.
  2. Need to add App42GCMReceiver in in receiver section that receives the push messages.

Will you please share the AndroidManifest.xml file, that will help us to trace the exact problem.

Thanks

Vishnu Garg

answered Apr 29, 2016 by Vishnu Garg (674 points)
the name of the app is UrbanDonate
i have added demo@shephertz.com as a collaborator
EDIT:
the push service is not working only on android 6.0
okay. i dont know what the issue was. but its got resolved now.

thanks a lot for your continuous support. much appreciated.
Hi Checker,

Thanks for adding us as a collaborator on your app. Could you please check the push message on device because i am able to see the success logs inside Push logs.

Regards,
Himanshu sharma
Great to know that the issue has been resolved for you. Please feel free to write us in case you need further help.

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...