The pushidentifier is a string that contains the device token for Push notifications. It is the same token that is sent by Firebase and is passed to the SDK using the MobileCore.setPushIdentifier method.
Open your project in Android™ studio. Delete the entire code in MainActivity except the first line which is your package statement.
Paste the following code into MainActivity:
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.adobe.marketing.mobile.MobileCore;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
registerToken();
}
void registerToken() {
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w("Message App", "getInstanceId failed", task.getException());
return;
}
// Get new Instance ID token
String token = task.getResult().getToken();
Log.d("Got token", token);
MobileCore.setPushIdentifier(token);
}
});
}
@Override
public void onResume() {
super.onResume();
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}
@Override
public void onPause() {
super.onPause();
MobileCore.lifecyclePause();
}
}
Now is a good time to test your app, before going any further.
Log in to your Adobe Campaign Standard instance.
Navigate Administration->Channels->Mobile App(Experience Platform SDK). Open the appropriate mobile application. Tab to the Mobile Application Subscribers tab. You should see a registration token listed.
If you do not see registration token in the Mobile Application Subscribers tab STOP here before proceeding any further.