Как я могу хранить pushy токены в базе данных - PullRequest
0 голосов
/ 17 января 2020

использую pushy для push notifications, но не могу сохранить device token в database.

    private class RegisterForPushNotificationsAsync extends AsyncTask<Void, Void, Exception> {
    protected Exception doInBackground(Void... params) {
        try {
            // Assign a unique token to this device
            String deviceToken = Pushy.register(getApplicationContext());


            // Log it for debugging purposes
            Log.d("MyApp", "Pushy device token: " + deviceToken);

            // Send the token to your backend server via an HTTP GET request
            new URL("https://key}/register/device?token=" + deviceToken).openConnection();
        } catch (Exception exc) {
            // Return exc to onPostExecute
            return exc;
        }

        // Success
        return null;
    }

    @Override
    protected void onPostExecute(Exception exc) {
        // Failed?
        if (exc != null) {
            // Show error as toast message
            Toast.makeText(getApplicationContext(), exc.toString(), Toast.LENGTH_LONG).show();
            return;
        }

        // Succeeded, optionally do something to alert the user
    }
}

Я использую retrofit для http requests и не использую любой вид backend system

...