Skip to content

Commit f6aa77f

Browse files
committed
Added Passkit fluent api for apple
1 parent 92b57cb commit f6aa77f

File tree

2 files changed

+64
-48
lines changed

2 files changed

+64
-48
lines changed

PushSharp.Apple/AppleFluentNotification.cs

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ public static AppleNotification WithCustomItem(this AppleNotification n, string
9898
return n;
9999
}
100100

101+
public static AppleNotification WithPasskitUpdate(this AppleNotification n)
102+
{
103+
var payLoad = new AppleNotificationPayload();
104+
payLoad.AddCustom("aps", string.Empty);
105+
106+
n.Payload = payLoad;
107+
108+
return n;
109+
}
110+
101111
public static AppleNotification WithTag(this AppleNotification n, object tag)
102112
{
103113
n.Tag = tag;

PushSharp.Sample/Program.cs

+54-48
Original file line numberDiff line numberDiff line change
@@ -33,56 +33,62 @@ static void Main(string[] args)
3333
// and one for connecting to Production. You must use the right one, to match the provisioning profile you build your
3434
// app with!
3535
var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Resources/PushSharp.Apns.Sandbox.p12"));
36-
37-
//IMPORTANT: If you are using a Development provisioning Profile, you must use the Sandbox push notification server
38-
// (so you would leave the first arg in the ctor of ApplePushChannelSettings as 'false')
39-
// If you are using an AdHoc or AppStore provisioning profile, you must use the Production push notification server
40-
// (so you would change the first arg in the ctor of ApplePushChannelSettings to 'true')
41-
push.StartApplePushService(new ApplePushChannelSettings(appleCert, "pushsharp"));
42-
43-
//Configure and start Android GCM
44-
//IMPORTANT: The SENDER_ID is your Google API Console App Project ID.
45-
// Be sure to get the right Project ID from your Google APIs Console. It's not the named project ID that appears in the Overview,
46-
// but instead the numeric project id in the url: eg: https://code.google.com/apis/console/?pli=1#project:785671162406:overview
47-
// where 785671162406 is the project id, which is the SENDER_ID to use!
48-
push.StartGoogleCloudMessagingPushService(new GcmPushChannelSettings("785671162406", "AIzaSyC2PZNXQDVaUpZGmtsF_Vp8tHtIABVjazI", "com.pushsharp.test"));
49-
50-
//Configure and start Windows Phone Notifications
51-
push.StartWindowsPhonePushService(new WindowsPhonePushChannelSettings());
36+
37+
//IMPORTANT: If you are using a Development provisioning Profile, you must use the Sandbox push notification server
38+
// (so you would leave the first arg in the ctor of ApplePushChannelSettings as 'false')
39+
// If you are using an AdHoc or AppStore provisioning profile, you must use the Production push notification server
40+
// (so you would change the first arg in the ctor of ApplePushChannelSettings to 'true')
41+
push.StartApplePushService(new ApplePushChannelSettings(appleCert, "pushsharp"));
42+
43+
//Configure and start Android GCM
44+
//IMPORTANT: The SENDER_ID is your Google API Console App Project ID.
45+
// Be sure to get the right Project ID from your Google APIs Console. It's not the named project ID that appears in the Overview,
46+
// but instead the numeric project id in the url: eg: https://code.google.com/apis/console/?pli=1#project:785671162406:overview
47+
// where 785671162406 is the project id, which is the SENDER_ID to use!
48+
push.StartGoogleCloudMessagingPushService(new GcmPushChannelSettings("785671162406", "AIzaSyC2PZNXQDVaUpZGmtsF_Vp8tHtIABVjazI", "com.pushsharp.test"));
49+
50+
//Configure and start Windows Phone Notifications
51+
push.StartWindowsPhonePushService(new WindowsPhonePushChannelSettings());
5252

5353
//Configure and start Windows Notifications
54-
push.StartWindowsPushService(new WindowsPushChannelSettings("BUILD.64beb1a1-5444-4660-8b27-bcc740f9c7ca",
55-
"ms-app://s-1-15-2-259456210-2622405444-520366611-1750679940-1314087242-2560077863-3994015833", "7-GIUO1ubmrqOwQUBzXpnqiSw30LS2xr"));
56-
57-
//Fluent construction of a Windows Toast Notification
58-
push.QueueNotification(NotificationFactory.Windows().Toast().AsToastText01("This is a test").ForChannelUri("YOUR_CHANNEL_URI_HERE"));
59-
60-
//Fluent construction of a Windows Phone Toast notification
61-
//IMPORTANT: For Windows Phone you MUST use your own Endpoint Uri here that gets generated within your Windows Phone app itself!
62-
push.QueueNotification(NotificationFactory.WindowsPhone().Toast()
63-
.ForEndpointUri(new Uri("http://sn1.notify.live.net/throttledthirdparty/01.00/AAFCoNoCXidwRpn5NOxvwSxPAgAAAAADAgAAAAQUZm52OkJCMjg1QTg1QkZDMkUxREQ"))
64-
.ForOSVersion(WindowsPhone.WindowsPhoneDeviceOSVersion.MangoSevenPointFive)
65-
.WithBatchingInterval(WindowsPhone.BatchingInterval.Immediate)
66-
.WithNavigatePath("/MainPage.xaml")
67-
.WithText1("PushSharp")
68-
.WithText2("This is a Toast"));
69-
70-
//Fluent construction of an iOS notification
71-
//IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets generated within your iOS app itself when the Application Delegate
72-
// for registered for remote notifications is called, and the device token is passed back to you
73-
push.QueueNotification(NotificationFactory.Apple()
74-
.ForDeviceToken("1071737321559691b28fffa1aa4c8259d970fe0fc496794ad0486552fc9ec3db")
75-
.WithAlert("1 Alert Text!")
76-
.WithSound("default")
77-
.WithBadge(7));
78-
79-
//Fluent construction of an Android GCM Notification
80-
//IMPORTANT: For Android you MUST use your own RegistrationId here that gets generated within your Android app itself!
81-
push.QueueNotification(NotificationFactory.AndroidGcm()
82-
.ForDeviceRegistrationId("APA91bG7J-cZjkURrqi58cEd5ain6hzi4i06T0zg9eM2kQAprV-fslFiq60hnBUVlnJPlPV-4K7X39aHIe55of8fJugEuYMyAZSUbmDyima5ZTC7hn4euQ0Yflj2wMeTxnyMOZPuwTLuYNiJ6EREeI9qJuJZH9Zu9g")
83-
.WithCollapseKey("NONE")
84-
.WithJson("{\"alert\":\"Alert Text!\",\"badge\":\"7\"}"));
85-
54+
push.StartWindowsPushService(new WindowsPushChannelSettings("677AltusApps.PushSharpTest",
55+
"ms-app://s-1-15-2-397915024-884168245-3562497613-3307968140-4074292843-797285123-433377759", "ei5Lott1HEbbZBv2wGDTUsrCjU++Pj8Z"));
56+
57+
//Fluent construction of a Windows Toast Notification
58+
push.QueueNotification(NotificationFactory.Windows().Toast().AsToastText01("This is a test").ForChannelUri("YOUR_CHANNEL_URI_HERE"));
59+
60+
//Fluent construction of a Windows Phone Toast notification
61+
//IMPORTANT: For Windows Phone you MUST use your own Endpoint Uri here that gets generated within your Windows Phone app itself!
62+
push.QueueNotification(NotificationFactory.WindowsPhone().Toast()
63+
.ForEndpointUri(new Uri("http://sn1.notify.live.net/throttledthirdparty/01.00/AAFCoNoCXidwRpn5NOxvwSxPAgAAAAADAgAAAAQUZm52OkJCMjg1QTg1QkZDMkUxREQ"))
64+
.ForOSVersion(WindowsPhone.WindowsPhoneDeviceOSVersion.MangoSevenPointFive)
65+
.WithBatchingInterval(WindowsPhone.BatchingInterval.Immediate)
66+
.WithNavigatePath("/MainPage.xaml")
67+
.WithText1("PushSharp")
68+
.WithText2("This is a Toast"));
69+
70+
//Fluent construction of an iOS notification
71+
//IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets generated within your iOS app itself when the Application Delegate
72+
// for registered for remote notifications is called, and the device token is passed back to you
73+
push.QueueNotification(NotificationFactory.Apple()
74+
.ForDeviceToken("1071737321559691b28fffa1aa4c8259d970fe0fc496794ad0486552fc9ec3db")
75+
.WithAlert("1 Alert Text!")
76+
.WithSound("default")
77+
.WithBadge(7));
78+
79+
//Fluent construction of an Android GCM Notification
80+
//IMPORTANT: For Android you MUST use your own RegistrationId here that gets generated within your Android app itself!
81+
push.QueueNotification(NotificationFactory.AndroidGcm()
82+
.ForDeviceRegistrationId("APA91bG7J-cZjkURrqi58cEd5ain6hzi4i06T0zg9eM2kQAprV-fslFiq60hnBUVlnJPlPV-4K7X39aHIe55of8fJugEuYMyAZSUbmDyima5ZTC7hn4euQ0Yflj2wMeTxnyMOZPuwTLuYNiJ6EREeI9qJuJZH9Zu9g")
83+
.WithCollapseKey("NONE")
84+
.WithJson("{\"alert\":\"Alert Text!\",\"badge\":\"7\"}"));
85+
86+
push.QueueNotification(NotificationFactory.Windows()
87+
.Toast()
88+
.ForChannelUri("https://bn1.notify.windows.com/?token=AgUAAACC2u7flXAmaevcggrLenaSdExjVfIHvr6KSZrg0KeuGrcz877rPJprPL9bEuQH%2bacmmm%2beUyXNXEM8oRNit%2bzPoigksDOq6bIFyV3XGmhUmXadysLokl5rlmTscvHGAbs%3d")
89+
.WithRequestForStatus(true)
90+
.AsToastText01("This is a test!"));
91+
8692
Console.WriteLine("Waiting for Queue to Finish...");
8793

8894
//Stop and wait for the queues to drains

0 commit comments

Comments
 (0)