コード例 #1
0
        @Override
        public void execute() {

          QBSubscription subscription = new QBSubscription(QBNotificationChannel.GCM);
          subscription.setEnvironment(QBEnvironment.DEVELOPMENT);
          //
          String deviceId =
              ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
                  .getDeviceId();
          if (deviceId == null) {
            deviceId = "UniversalDeviceId";
          }
          subscription.setDeviceUdid(deviceId);
          //
          String registrationID =
              "APA91bGr9AcS9Wgv4p4BkBQAg_1YrJZpfa5GMXg7LAQU0lya8gbf9Iw1360602PunkWk_NOsLS2xEK8tPeBCBfSH4fobt7zW4KVlWGjUfR3itFbVa_UreBf6c-rZ8uP_0_vxPCO65ceqgnjvQqD6j8DjLykok7VF7UBBjsMZrTIFjKwmVeJqb1o";
          subscription.setRegistrationID(registrationID);

          QBPushNotifications.createSubscription(
              subscription,
              new QBEntityCallback<ArrayList<QBSubscription>>() {

                @Override
                public void onSuccess(ArrayList<QBSubscription> subscriptions, Bundle args) {
                  Log.i(TAG, ">>> Subscription: " + subscriptions.toString());
                }

                @Override
                public void onError(QBResponseException errors) {
                  handleErrors(errors);
                }
              });
        }
コード例 #2
0
        @Override
        public void executeAsync() {
          QBSubscription subscription = new QBSubscription(QBNotificationChannel.GCM);
          //
          subscription.setEnvironment(QBEnvironment.DEVELOPMENT);
          //
          String deviceId =
              ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
                  .getDeviceId();
          if (deviceId == null) {
            deviceId = "UniversalDeviceId";
          }
          subscription.setDeviceUdid(deviceId);
          //
          String registrationID =
              "APA91bGr9AcS9Wgv4p4BkBQAg_1YrJZpfa5GMXg7LAQU0lya8gbf9Iw1360602PunkWk_NOsLS2xEK8tPeBCBfSH4fobt7zW4KVlWGjUfR3itFbVa_UreBf6c-rZ8uP_0_vxPCO65ceqgnjvQqD6j8DjLykok7VF7UBBjsMZrTIFjKwmVeJqb1o";
          subscription.setRegistrationID(registrationID);

          ArrayList<QBSubscription> createdSubscriptions = null;
          try {
            createdSubscriptions = QBPushNotifications.createSubscription(subscription);
          } catch (QBResponseException e) {
            setException(e);
          }
          if (createdSubscriptions != null) {
            Log.i(TAG, ">>> Subscription: " + createdSubscriptions.toString());
          }
        }