私は取得と表示の通知に THES SORCE を使用しますが、このコードはカスタマイズしません。カスタマイズされた通知のソースが必要です onesignal.com から受け取りました
onesignal と Received で URL を送信し、アイコン通知用に表示する必要がある onesignal でタイトルを送信し、タイトルを設定する必要がある onesignal でディクリプションを送信し、ディクリプションを設定する必要がある URL を送信し、ヘルプのために uri タンクを設定する必要がある
package booke.vfj.angour.ir.baftani_davood;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.content.Context;
import android.view.LayoutInflater;
import org.json.JSONObject;
import java.util.ArrayList;
public class G extends Application {
public static Context context;
public static LayoutInflater inflater;
public static Activity currentActivity;
public static ArrayList<StructTest> Recordsfehrset = new ArrayList<StructTest>();
public static ArrayList<StructTest2> recordjoziat = new ArrayList<StructTest2>();
public static ArrayList<StructTest> fov = new ArrayList<StructTest>();
@Override
public void onCreate()
{
super.onCreate();
context = getApplicationContext();
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
OneSignal.startInit(this).init();
OneSignal.startInit(this).setNotificationOpenedHandler(new NotificationOpenedHandler()).init();
}
private class NotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
@Override
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
try {
String messageTitle;
AlertDialog.Builder builder = null;
if (additionalData != null) {
if (additionalData.has("discount"))
messageTitle = "Discount!";
else if (additionalData.has("bonusCredits"))
messageTitle = "Bonus Credits!";
else
messageTitle = "Other Extra Data";
builder = new AlertDialog.Builder(getApplicationContext()).setTitle(messageTitle).setMessage(message + "\n\n" + additionalData.toString());
}
else if (isActive) // If a push notification is received when the app is being used it does not display in the notification bar so display in the app.
builder = new AlertDialog.Builder(getApplicationContext())
.setTitle("OneSignal Message")
.setMessage(message);
// Add your app logic around this so the user is not interrupted during gameplay.
if (builder != null)
builder.setCancelable(true)
.setPositiveButton("OK",null)
.create().show();
} catch (Throwable t) {
t.printStackTrace();
}
}
}