当前位置: 首页>>代码示例>>Java>>正文


Java ParsePush.setData方法代码示例

本文整理汇总了Java中com.parse.ParsePush.setData方法的典型用法代码示例。如果您正苦于以下问题:Java ParsePush.setData方法的具体用法?Java ParsePush.setData怎么用?Java ParsePush.setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.parse.ParsePush的用法示例。


在下文中一共展示了ParsePush.setData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
    }
}
 
开发者ID:chechulinYuri,项目名称:stepout,代码行数:26,代码来源:ViewEventAsRespondentActivity.java

示例2: 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();
}
 
开发者ID:AvijitGhosh82,项目名称:Madad_SOS,代码行数:30,代码来源:AcceptSOS.java

示例3: 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("");
}
 
开发者ID:fitness-buddy,项目名称:Fitness-Buddy-Group-Project,代码行数:30,代码来源:ChatActivity.java

示例4: 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();
}
 
开发者ID:SCCapstone,项目名称:diet,代码行数:41,代码来源:ChatFragment.java

示例5: sendOy

import com.parse.ParsePush; //导入方法依赖的package包/类
public static void sendOy(String username, SendCallback callback) {
    try {
        String message = "From " + ParseUser.getCurrentUser().getUsername().toLowerCase();
        JSONObject data = new JSONObject("{\"action\": \"mohammad.adib.oy.UPDATE_STATUS\",\"alert\": \"" + message + "\"}");
        // Send push notification to query
        ParsePush push = new ParsePush();
        push.setChannel(username);
        push.setData(data);
        push.sendInBackground(callback);
    } catch (Exception e) {

    }
}
 
开发者ID:MohammadAdib,项目名称:Oy,代码行数:14,代码来源:OyUtils.java

示例6: updateEventStatus

import com.parse.ParsePush; //导入方法依赖的package包/类
@Subscribe
public void updateEventStatus(String status) {
    if (status.equals(DataExchange.STATUS_UPDATE_EVENT_SUCCESS)) {
        Toast.makeText(getApplicationContext(), getResources().getString(R.string.event_saved), Toast.LENGTH_LONG).show();

        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.author_updated_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();
    } else if(status.equals(DataExchange.STATUS_UPDATE_EVENT_FAIL)) {
        Toast.makeText(getApplicationContext(), getResources().getString(R.string.some_error), Toast.LENGTH_LONG).show();
    }

    Intent intent = new Intent(this, ViewEventAsAuthorActivity.class);
    intent.putExtra(DataExchange.EVENT_HASH_FOR_VIEW_EVENT_ACTIVITY_KEY, currentEvent.getHash());
    startActivity(intent);

    Util.dismissLoadingDialog();
    isSavingProcess = false;
}
 
开发者ID:chechulinYuri,项目名称:stepout,代码行数:29,代码来源:EditEventActivity.java


注:本文中的com.parse.ParsePush.setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。