Usage

To make use of the functionalities that the Messanging SDK offers, utilize the Messaging class.

To obtain the instance of this class:

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
Messaging messaging=Messaging.getInstance(this);
}
//get Instance of Messaging.. 

All the services offered by this library are provided by means of an instance of the Messaging class, and it can be obtained that it was indicated later.

Obtain User Data

Method to obtain each User by Device that is registered from the service.

Whenforsecallservice=true, search device parameters through the service.

@Override
protected void onResume() {
   super.onResume();
Messaging.fetchUser(getApplicationContext(), true);
}

you can use in the activity:

    messagingUser.addProperty(key,value);

For asing property to the user, example of a Property: Juan, Alvarado, ja@gmail.com or 555-55-55, and example of key : example name, LastName or Phone.

then for update User data, you can use:

messagingUser.save(getApplicationContext());;

This method usesLocalBroadcastReceiver to send Instance from the SDK to Activity. (Please refer to Step 1).

Obtain Device

Receive the OS version of the user’s device, example:

@Override
    protected void onStart() {
        super.onStart();
       LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver,
                new IntentFilter(Messaging.ACTION_FETCH_DEVICE));
      }
       ...
      @Override
    protected void onResume() {
        super.onResume();
       Messaging.fetchDevice(false);
    }
    private BroadcastReceiver mReceiver=new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            boolean hasError=intent.getBooleanExtra(Messaging.INTENT_EXTRA_HAS_ERROR,true);
            
            if (!hasError ) {
                Serializable data=intent.getSerializableExtra(Messaging.INTENT_EXTRA_DATA);
                if(intent.getAction().equals(Messaging.ACTION_FETCH_DEVICE)&& data!=null){
                    messagingDevice = (MessagingDevice) data; //you can cast this for get information
                    .....
                }else if(intent.getAction().equals(Messaging.ACTION_FETCH_USER)&& data!=null){
                    messagingUser =(MessagingUser) data;
                    .......
                
            }else{
                Toast.makeText(getApplicationContext(),"An error occurred on action "
                        +intent.getAction(),Toast.LENGTH_LONG).show();
            }
            ......
        }
    };
   //you can see all the implementation in example app
     @Override
    protected void onDestroy() {
     LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
     }

MessagingDevice is used to handle Device parameters in the SDK.

To obtain this device instance, the SDK can provide it in three ways:

  • local memory

  • internal memory

  • service

To add a Tag to a Device, you may Save and it will immediately be updated in the database.

     messagingDev.addTagToDevice(tags);

This method usesBroadcastReceiver to send Instance from the SDK to Activity. (Please refer to Step 1).

     messagingDevice.save(getApplicationContext());
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.