Click here to Skip to main content
15,794,593 members
Home / Discussions / C#
   

C#

 
GeneralRe: how can i set windows form over other programs at the desktop in c# Pin
Eddy Vluggen6-Mar-18 3:04
professionalEddy Vluggen6-Mar-18 3:04 
AnswerRe: how can i set windows form over other programs at the desktop in c# Pin
Gerry Schmitz6-Mar-18 7:07
mveGerry Schmitz6-Mar-18 7:07 
AnswerRe: how can i set windows form over other programs at the desktop in c# Pin
Dave Kreskowiak8-Mar-18 5:16
mveDave Kreskowiak8-Mar-18 5:16 
Questionapple push notification Pin
Member 108437285-Mar-18 21:22
Member 108437285-Mar-18 21:22 
AnswerRe: apple push notification Pin
Pete O'Hanlon5-Mar-18 21:28
subeditorPete O'Hanlon5-Mar-18 21:28 
GeneralRe: apple push notification Pin
Member 108437285-Mar-18 21:35
Member 108437285-Mar-18 21:35 
GeneralRe: apple push notification Pin
Pete O'Hanlon5-Mar-18 21:54
subeditorPete O'Hanlon5-Mar-18 21:54 
GeneralRe: apple push notification Pin
Member 108437285-Mar-18 22:11
Member 108437285-Mar-18 22:11 
this is my code

int port = 2195;
            String hostname = "gateway.push.apple.com";

try
           {
               TcpClient client = new TcpClient(hostname, port);
               SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

               try
               {
                   sslStream.AuthenticateAsClient(hostname, certificatesCollection, System.Security.Authentication.SslProtocols.Tls, false);

                   for (int i = 0; i < Token.Length; i++)
                   {
                       HttpContext.Current.Trace.Warn("inside sendPushNotificationApple, dt=" + Token[i]);
                       MemoryStream memoryStream = new MemoryStream();
                       BinaryWriter writer = new BinaryWriter(memoryStream);
                       writer.Write((byte)0);
                       writer.Write((byte)0);
                       writer.Write((byte)32);

                       writer.Write(HexStringToByteArray(Token[i]));
                       String payload = "{ \"aps\" : { \"alert\" : {\"title\" : \"" + szAppName + "\",\"body\" : \"" + message + "\",\"Type\" : \"" + szType + "\"} }}";
                       HttpContext.Current.Trace.Warn("inside sendPushNotificationApple, payload=" + payload.ToString());
                       writer.Write((byte)0);
                       //writer.Write((byte)payload.Length);
                       byte[] b1 = System.Text.Encoding.UTF8.GetBytes(payload);
                       writer.Write((byte)b1.Length);
                       writer.Write(b1);
                       writer.Flush();
                       byte[] array = memoryStream.ToArray();
                       sslStream.Write(array);
                       sslStream.Flush();
                   }

                   client.Close();
               }
               catch (System.Security.Authentication.AuthenticationException ex)
               {
                   HttpContext.Current.Trace.Warn("inside sendPushNotificationApple, AuthenticationException=" + ex.ToString());
                   client.Close();
               }
               catch (Exception exp)
               {
                   HttpContext.Current.Trace.Warn("inside sendPushNotificationApple, Exception=" + exp.ToString());
                   client.Close();
               }
           }
           catch (Exception ex)
           {
               HttpContext.Current.Trace.Warn("inside sendPushNotificationApple, Exception1=" + ex.ToString());
           }

GeneralRe: apple push notification Pin
Gerry Schmitz6-Mar-18 6:58
mveGerry Schmitz6-Mar-18 6:58 
QuestionTaskFactory Class Pin
Member 137105305-Mar-18 17:37
Member 137105305-Mar-18 17:37 
AnswerRe: TaskFactory Class Pin
Pete O'Hanlon5-Mar-18 21:20
subeditorPete O'Hanlon5-Mar-18 21:20 
GeneralRe: TaskFactory Class Pin
Member 137105307-Mar-18 7:13
Member 137105307-Mar-18 7:13 
AnswerRe: TaskFactory Class Pin
Gerry Schmitz7-Mar-18 8:40
mveGerry Schmitz7-Mar-18 8:40 
GeneralRe: TaskFactory Class Pin
Member 1371053019-Mar-18 19:00
Member 1371053019-Mar-18 19:00 
Questionc# parsing CAN dbc files Pin
Member 135713645-Mar-18 5:05
Member 135713645-Mar-18 5:05 
AnswerRe: c# parsing CAN dbc files Pin
Maciej Los5-Mar-18 21:27
mveMaciej Los5-Mar-18 21:27 
GeneralRe: c# parsing CAN dbc files Pin
Member 135713645-Mar-18 21:34
Member 135713645-Mar-18 21:34 
Questiontextbox input Pin
User 136751143-Mar-18 14:01
User 136751143-Mar-18 14:01 
AnswerRe: textbox input Pin
BillWoodruff3-Mar-18 15:31
professionalBillWoodruff3-Mar-18 15:31 
GeneralRe: textbox input Pin
User 136751144-Mar-18 0:56
User 136751144-Mar-18 0:56 
GeneralRe: textbox input Pin
OriginalGriff4-Mar-18 2:21
mvaOriginalGriff4-Mar-18 2:21 
GeneralRe: textbox input Pin
BillWoodruff4-Mar-18 3:18
professionalBillWoodruff4-Mar-18 3:18 
GeneralRe: textbox input Pin
Luc Pattyn4-Mar-18 8:19
sitebuilderLuc Pattyn4-Mar-18 8:19 
GeneralRe: textbox input Pin
OriginalGriff4-Mar-18 20:27
mvaOriginalGriff4-Mar-18 20:27 
GeneralRe: textbox input Pin
Pete O'Hanlon4-Mar-18 21:56
subeditorPete O'Hanlon4-Mar-18 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.