I signed up for a Pusher/Beams account for my Android app. I was able to set it up no problem. But when I went to simply create a new pushnotification instance I ran into an error. The documentation from Pusher uses this code:
String instanceId = "YOUR_INSTANCE_ID_HERE";
String secretKey = "YOUR_SECRET_KEY_HERE";
PushNotifications pushNotifications = new PushNotifications(instanceId,secretKey);
However when I literally copy and paste that into Android Studios I get an error saying PushNotifications does not accept Strings. I am baffled as to why this is happening. Here is my code:
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.pusher.pushnotifications.PushNotifications;
public class MainActivity extends AppCompatActivity {
String instanceId = "YOUR_INSTANCE_ID_HERE";
String secretKey = "YOUR_SECRET_KEY_HERE";
PushNotifications pushNotifications = new PushNotifications(instanceId, secretKey);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PushNotifications.start(getApplicationContext(), "my_instance_id");
PushNotifications.subscribe("hello");
}
Here is a screenshot of the error.
You can not pass string as first argument to PushNotification constructor. You are passing incorrect parameters.
Current is:
PushNotifications pushNotifications = new PushNotifications(instanceId, secretKey);
Change to:
PushNotificationsInstance pushNotifications =
new PushNotificationsInstance(getApplicationContext(), instanceId);
It will work.
Check here for more information : https://docs.pusher.com/beams/reference/android#quickstart