Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AndroidNotification.cs #32

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 171 additions & 156 deletions cn.jpush.api/push/notification/AndroidNotification.cs
Original file line number Diff line number Diff line change
@@ -1,166 +1,181 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

namespace cn.jpush.api.push.notification
{
public class AndroidNotification : PlatformNotification
{
public const string NOTIFICATION_ANDROID = "android";

private const string TITLE = "title";
private const string BUILDER_ID = "builder_id";

[JsonProperty]
public string title { get; private set; }

[JsonProperty]
public int builder_id { get; private set; }

[JsonProperty]
public int priority { get; private set; }

[JsonProperty]
public string category { get; private set; }

[JsonProperty]
public int style { get; private set; }

[JsonProperty]
public int alert_type { get; private set; }

[JsonProperty]
public string big_text { get; private set; }

[JsonProperty]
public string inbox { get; private set; }

[JsonProperty]
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace cn.jpush.api.push.notification
{
public class AndroidNotification : PlatformNotification
{
public const string NOTIFICATION_ANDROID = "android";
private const string TITLE = "title";
private const string BUILDER_ID = "builder_id";
[JsonProperty]
public string title { get; private set; }
[JsonProperty]
public int builder_id { get; private set; }
[JsonProperty]
public int priority { get; private set; }
[JsonProperty]
public string category { get; private set; }
[JsonProperty]
public int style { get; private set; }
[JsonProperty]
public int alert_type { get; private set; }
[JsonProperty]
public string big_text { get; private set; }
[JsonProperty]
public string inbox { get; private set; }
[JsonProperty]
public string big_pic_path { get; private set; }

// 华为 only - start

/// <summary>
/// 指定开发者想要打开的 Activity,值为 <activity> 节点的 "android:name" 属性值。
/// </summary>
[JsonProperty]
public string uri_activity { get; private set; }

// 华为 only - end

public AndroidNotification() : base()
{
title = null;
builder_id = 0;
}

public AndroidNotification setTitle(string title)
{
this.title = title;
return this;
}

public AndroidNotification setBuilderID(int builder_id)
{
this.builder_id = builder_id;
return this;
}

public AndroidNotification setAlert(string alert)
{
this.alert = alert;
return this;
}

public AndroidNotification setPriority(int priority)
{
this.priority = priority;
return this;
}

public AndroidNotification setCategory(string category)
{
this.category = category;
return this;
}

public AndroidNotification setStyle(int style)
{
this.style = style;
return this;
}

public AndroidNotification setAlert_type(int alert_type)
{
this.alert_type = alert_type;
return this;
}

public AndroidNotification setBig_text(string big_text)
{
this.big_text = big_text;
return this;
}

public AndroidNotification setInbox(string inbox)
{
this.inbox = inbox;
return this;
}

public AndroidNotification setBig_pic_path(string big_pic_path)
{
this.big_pic_path = big_pic_path;
return this;
}

/// </summary>
[JsonProperty]
public string uri_activity { get; private set; }

// 华为 only - end

// oppo only - start

/// <summary>
/// 指定开发者想要打开的 Activity,值为 <activity> 节点的 "android:name" 属性值。
/// </summary>
[JsonProperty]
public string uri_action { get; private set; }

// oppo only - end

public AndroidNotification() : base()
{
title = null;
builder_id = 0;
}

public AndroidNotification setTitle(string title)
{
this.title = title;
return this;
}

public AndroidNotification setBuilderID(int builder_id)
{
this.builder_id = builder_id;
return this;
}

public AndroidNotification setAlert(string alert)
{
this.alert = alert;
return this;
}

public AndroidNotification setPriority(int priority)
{
this.priority = priority;
return this;
}

public AndroidNotification setCategory(string category)
{
this.category = category;
return this;
}

public AndroidNotification setStyle(int style)
{
this.style = style;
return this;
}

public AndroidNotification setAlert_type(int alert_type)
{
this.alert_type = alert_type;
return this;
}

public AndroidNotification setBig_text(string big_text)
{
this.big_text = big_text;
return this;
}

public AndroidNotification setInbox(string inbox)
{
this.inbox = inbox;
return this;
}

public AndroidNotification setBig_pic_path(string big_pic_path)
{
this.big_pic_path = big_pic_path;
return this;
}

public AndroidNotification setUriActivity(string uri_activity)
{
this.uri_activity = uri_activity;
return this;
}

public AndroidNotification AddExtra(string key, string value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
if (value != null)
{
extras.Add(key, value);
}
return this;
}

public AndroidNotification AddExtra(string key, int value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
extras.Add(key, value);
return this;
}

public AndroidNotification AddExtra(string key, bool value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
extras.Add(key, value);
return this;
}

public AndroidNotification AddExtra(string key, object value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
extras.Add(key, value);
return this;
}
}
}
}
public AndroidNotification setUriAction(string uri_action)
{
this.uri_action = uri_action;
return this;
}

public AndroidNotification AddExtra(string key, string value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
if (value != null)
{
extras.Add(key, value);
}
return this;
}

public AndroidNotification AddExtra(string key, int value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
extras.Add(key, value);
return this;
}

public AndroidNotification AddExtra(string key, bool value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
extras.Add(key, value);
return this;
}

public AndroidNotification AddExtra(string key, object value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
extras.Add(key, value);
return this;
}
}
}