本文整理汇总了Java中com.parse.ParsePush类的典型用法代码示例。如果您正苦于以下问题:Java ParsePush类的具体用法?Java ParsePush怎么用?Java ParsePush使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParsePush类属于com.parse包,在下文中一共展示了ParsePush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupParse
import com.parse.ParsePush; //导入依赖的package包/类
private void setupParse() {
Parse.initialize(this);
Parse.setLogLevel(
BuildConfig.DEBUG ?
Parse.LOG_LEVEL_VERBOSE :
Parse.LOG_LEVEL_NONE);
ParseInstallation parseInstallation = ParseInstallation.getCurrentInstallation();
parseInstallation.increment("uses");
parseInstallation.saveInBackground();
ParsePush.subscribeInBackground("");
ParsePush.subscribeInBackground("general");
ParsePush.subscribeInBackground("warning");
ParsePush.subscribeInBackground("news");
ParseLocation.registerSubclass(ParseLocation.class);
Schedule.registerSubclass(Schedule.class);
Price.registerSubclass(Price.class);
New.registerSubclass(New.class);
}
示例2: setUpParse
import com.parse.ParsePush; //导入依赖的package包/类
public static void setUpParse(Context context) {
Parse.enableLocalDatastore(context);
Parse.initialize(context, "SUA_APPLICATION_ID", "SUA CLIENT_KEY");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
defaultACL.setPublicWriteAccess(true);
ParsePush.subscribeInBackground(Constants.CHANNEL, new SaveCallback() {
@Override
public void done(ParseException error) {
if (error == null) {
Log.i(Constants.TAG, "Successfully subscribed to Parse!");
}else{
Log.i(Constants.TAG, "Error subscribed to Parse!");
}
}
});
}
示例3: onCreate
import com.parse.ParsePush; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this);
Parse.initialize(this, "b6M7rAxtdYoUgGMgGkzmYmpDWiN2T6M8c2RTJ5Zg", "Xsqyd44kUtgiOMMvwP8gyVjmdZLvXLxuynmGqqNX");
ParsePush.subscribeInBackground("Apro_2016", new SaveCallback() {
@Override
public void done(ParseException e) {
Log.e(TAG, "Successfully subscribed to Parse!");
}
});
Log.d(TAG, "not rgtd.");
}
示例4: onCreate
import com.parse.ParsePush; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
ParseCrashReporting.enable(this);
Parse.initialize(this, BuildConfig.PARSE_APPKEY,
BuildConfig.PARSE_TOKEN);
ParsePush.subscribeInBackground("wc", new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.e("push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("push", "failed to subscribe for push", e);
}
}
});
}
示例5: removeWC
import com.parse.ParsePush; //导入依赖的package包/类
@Override
public void removeWC() {
List<Integer> removedWCIDs = new ArrayList<>();
Collections.sort(deleteItems);
for (int i = deleteItems.size() - 1; i >= 0; i--) {
WordCampDB db = adapter.getItem(deleteItems.get(i));
removedWCIDs.add(db.getWc_id());
myWordCampDBs.remove((int) deleteItems.get(i));
if (!db.getTwitter().isEmpty()) {
ParsePush.unsubscribeInBackground(db.getTwitter().replace("#", ""));
}
}
deleteItems = new ArrayList<>();
communicator.removeFromMyWC(removedWCIDs);
adapter = new MyWCListAdapter(myWordCampDBs, getActivity(), this);
myWCLists.setAdapter(adapter);
((BaseActivity) getActivity()).refreshUpcomingFrag();
((BaseActivity) getActivity()).refreshPastFrag();
}
示例6: getUnresponseStatus
import com.parse.ParsePush; //导入依赖的package包/类
@Subscribe
public void getUnresponseStatus(String status) {
Util.dismissLoadingDialog();
if (status.equals(DataExchange.STATUS_SUCCESS)) {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.you_unrespond), Toast.LENGTH_LONG).show();
PushService.unsubscribe(getApplicationContext(), DataExchange.PREFIX_FOR_CHANNEL_NAME + currentEvent.getHash());
ParsePush push = new ParsePush();
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereNotEqualTo("installationId", ParseInstallation.getCurrentInstallation().getInstallationId());
pushQuery.whereEqualTo("channels", DataExchange.PREFIX_FOR_CHANNEL_NAME + currentEvent.getHash());
push.setQuery(pushQuery);
try {
JSONObject data = new JSONObject("{\"action\": \"com.stepout.main.CustomReceiver.SHOW_EVENT\", \"message\": \"" + getString(R.string.user_do_not_attend_event, currentEvent.getRespondentsHash().size()) + "\", \"" + DataExchange.EVENT_HASH_FOR_VIEW_EVENT_ACTIVITY_KEY + "\": \"" + currentEvent.getHash() + "\", \"author\": \"" + currentEvent.getAuthorHash() + "\"}");
push.setData(data);
} catch (JSONException e) {
e.printStackTrace();
}
push.sendInBackground();
Intent intentDeletion = new Intent(this, MapsActivity.class);
startActivity(intentDeletion);
} else if (status.equals(DataExchange.STATUS_FAIL)) {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.some_error), Toast.LENGTH_LONG).show();
}
}
示例7: removeEventStatus
import com.parse.ParsePush; //导入依赖的package包/类
@Subscribe
public void removeEventStatus(String status) {
Util.dismissLoadingDialog();
if (status.equals(DataExchange.STATUS_REMOVE_SUCCESS)) {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.remove_success), Toast.LENGTH_LONG).show();
PushService.unsubscribe(getApplicationContext(), DataExchange.PREFIX_FOR_CHANNEL_NAME + currentEvent.getHash());
ParsePush push = new ParsePush();
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereNotEqualTo("installationId", ParseInstallation.getCurrentInstallation().getInstallationId());
pushQuery.whereEqualTo("channels", DataExchange.PREFIX_FOR_CHANNEL_NAME + currentEvent.getHash());
push.setQuery(pushQuery);
push.setMessage(getString(R.string.author_deleted_event, android.text.format.DateFormat.format("dd.MM.yy hh:mm", currentEvent.getDate())));
push.sendInBackground();
Intent intent = new Intent(this, MapsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else if (status.equals(DataExchange.STATUS_REMOVE_FAIL)) {
isRemovingProcess = false;
Toast.makeText(getApplicationContext(), getResources().getString(R.string.some_error), Toast.LENGTH_LONG).show();
}
}
示例8: notifySOS
import com.parse.ParsePush; //导入依赖的package包/类
public void notifySOS() {
Log.d("AcceptedSOS","notifying");
// Find users near a given location
ParseQuery<ParseUser> userQuery = ParseUser.getQuery();
userQuery.whereEqualTo("username", senderId);
// Find devices associated with these users
ParseQuery<ParseInstallation> pushQuery = ParseInstallation.getQuery();
pushQuery.whereMatchesQuery("user", userQuery);
JSONObject jo = new JSONObject();
try {
jo.put("title", "Someone is coming to help you!");
jo.put("alert", "Ya! I'm coming!");
jo.put("sosId", SOSid);
jo.put("chatChannel", channelId);
jo.put("username", ParseUser.getCurrentUser().getUsername());
jo.put("type", "helping");
jo.put("displayname", displayname);
} catch (JSONException e) {
e.printStackTrace();
}
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery); // Set our Installation query
push.setData(jo);
push.sendInBackground();
}
示例9: sendPushNotifications
import com.parse.ParsePush; //导入依赖的package包/类
protected void sendPushNotifications() {
ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
query.whereContainedIn(ParseConstants.KEY_USER_ID, getRecipientIds());
// send push notification
ParsePush push = new ParsePush();
push.setQuery(query);
push.setMessage(getString(R.string.push_message,
ParseUser.getCurrentUser().getUsername()));
push.sendInBackground();
}
示例10: addToMyWC
import com.parse.ParsePush; //导入依赖的package包/类
@Override
public int addToMyWC(int wcid, int position) {
int retId = communicator.addToMyWC(wcid);
WordCampDB wordCampDB = adapter.getItem(position);
listener.onNewMyWCAdded(wordCampDB);
if (!wordCampDB.getTwitter().isEmpty()) {
ParsePush.subscribeInBackground(wordCampDB.getTwitter().replace("#", ""));
}
return retId;
}
示例11: removeMyWC
import com.parse.ParsePush; //导入依赖的package包/类
@Override
public void removeMyWC(int wcid, int position) {
communicator.removeFromMyWCSingle(wcid);
WordCampDB wordCampDB = adapter.getItem(position);
if (!wordCampDB.getTwitter().isEmpty()) {
ParsePush.unsubscribeInBackground(wordCampDB.getTwitter().replace("#", ""));
}
listener.onMyWCRemoved(wordCampDB);
}
示例12: onSendClicked
import com.parse.ParsePush; //导入依赖的package包/类
public void onSendClicked(View view) {
Message message = new Message();
message.setFromObjectId(m_me.objectId);
message.setToObjectId(m_other.objectId);
message.setText(etMessage.getText().toString());
message.saveInBackground();
messagesAdapter.add(message);
lvMessages.setSelection(lvMessages.getCount() - 1);
try {
ChatNotification notification = new ChatNotification();
notification.from = m_me;
notification.to = m_other;
notification.text = etMessage.getText().toString();
String jsonString = new Gson().toJson(notification);
JSONObject jsonObject = new JSONObject(jsonString);
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("channels", "");
ParsePush push = new ParsePush();
push.setQuery(pushQuery);
push.setData(jsonObject);
push.sendInBackground();
} catch (JSONException e) {
e.printStackTrace();
}
etMessage.setText("");
}
示例13: onCreate
import com.parse.ParsePush; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// Register your parse models here
ParseObject.registerSubclass(Address.class);
ParseObject.registerSubclass(Gym.class);
ParseObject.registerSubclass(Message.class);
ParseObject.registerSubclass(SimpleUser.class);
ParseObject.registerSubclass(Trainer.class);
ParseObject.registerSubclass(Review.class);
ParseObject.registerSubclass(TrainerSlots.class);
ParseObject.registerSubclass(BlockedSlots.class);
Parse.enableLocalDatastore(this);
Parse.initialize(this, APPLICATION_ID, CLIENT_KEY);
ParsePush.subscribeInBackground("", new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
PushService.setDefaultPushCallback(getBaseContext(), ChatActivity.class);//change the class where u want to go after clicking on noti
ParseInstallation.getCurrentInstallation().saveInBackground();
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
});
FacebookSdk.sdkInitialize(getApplicationContext());
}
示例14: sendPush
import com.parse.ParsePush; //导入依赖的package包/类
/**
* Sends a push notification to the recipient of a message. The push notification has the
* following fields (in a JSONObject):
*
* isChat - always true
* messageId - objectId of the message
* messageStr - The message's string representation
* fromUserId - objectId of the current user
* fromUserName - username of the current user
* title - title of the push notification ("New message from [username]")
* alert - the notification's message (the message string)
*
* @param message The message to push
*/
private void sendPush(Message message){
ParsePush push = new ParsePush();
ParseQuery<ParseInstallation> installationQuery = ParseInstallation.getQuery();
JSONObject pushData = new JSONObject();
installationQuery.whereEqualTo("user", otherUser);
try{
pushData.put("isChat", true);
pushData.put("messageId", message.getObjectId());
pushData.put("messageStr", message.getMessage());
pushData.put("fromUserId", ParseUser.getCurrentUser().getObjectId());
pushData.put("fromUserName", ParseUser.getCurrentUser().getUsername());
pushData.put("title", String.format(
"New message from %s", ParseUser.getCurrentUser().getUsername()
));
pushData.put("alert", message.getMessage());
} catch(JSONException e){
Log.d(TAG, e.getMessage());
updateToast("JSON exception occurred", Toast.LENGTH_LONG);
}
push.setQuery(installationQuery);
push.setData(pushData);
push.sendInBackground();
}
示例15: sendPushNotifications
import com.parse.ParsePush; //导入依赖的package包/类
protected void sendPushNotifications(){
//Parse installation object is used to associate users and send pushes only to intended users.
ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
query.whereContainedIn(ParseConstants.KEY_USER_ID, getRecipientIds());
//send the push notification
ParsePush push = new ParsePush();
push.setQuery(query);
push.setMessage(getString(R.string.push_message,
ParseUser.getCurrentUser().getUsername()));
push.sendInBackground();
}