Skip to content

Commit

Permalink
set push custom ringtone.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinanzhuan committed Aug 20, 2020
1 parent 3fd290c commit 5d6966a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions app/src/main/java/com/hyphenate/chatuidemo/ui/CallActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import com.hyphenate.util.EMLog;
import com.hyphenate.chat.EMWaterMarkPosition;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.InputStream;

@SuppressLint("Registered")
Expand Down Expand Up @@ -89,10 +92,32 @@ public void onRemoteOffline(final String to) {

final EMMessage message = EMMessage.createTxtSendMessage("You have an incoming call", to);
// set the user-defined extension field
message.setAttribute("em_apns_ext", true);
JSONObject apns = new JSONObject();
try {
apns.put("em_push_sound", "ring.caf");
} catch (JSONException e) {
e.printStackTrace();
}
message.setAttribute("em_apns_ext", apns);

message.setAttribute("is_voice_call", callType == 0 ? true : false);


JSONObject extObject = new JSONObject();
try {
extObject.put("type", "call");
} catch (JSONException e) {
e.printStackTrace();
}
message.setAttribute("em_push_ext", extObject);


JSONObject sound = new JSONObject();
try {
sound.put("em_push_sound", "/raw/ring");
} catch (JSONException e) {
e.printStackTrace();
}
message.setAttribute("em_android_push_ext", sound);
message.setMessageStatusCallback(new EMCallBack(){

@Override
Expand Down
Binary file added app/src/main/res/raw/ring.mp3
Binary file not shown.

0 comments on commit 5d6966a

Please sign in to comment.