Sending Push notification to a Windows Phone 7 device?

This question has received: 0 Votes.

So if I have my own game and server, how can I send push notifications to that device from my server, you know like a message that the application reads and display it to the user on the screen?

Sorry Im a noob when it comes to push notifications.

Sun May 22 16:42:42 AST 2011
Answer #: 1
This answer has received: 2 Votes.

Where have you started looking?

Windows Phone 7 supports a few different notifications, such as Toast, Live Tiles, Raw, etc.

I’d recommend starting here and reading about them a bit more, and follow the links to the appropriate documentation and examples.

Sun May 22 16:48:40 AST 2011
Answer #: 2
This answer has received: 1 Votes.

I am sending you the working code for toast push notification.

String toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
 "<wp:Notification xmlns:wp=\"WPNotification\">" +
     "<wp:Toast>" +
          "<wp:Text1> Welcome To Windows Push &lt;/wp:Text1>" +
     "</wp:Toast> " +
  "</wp:Notification>";


byte[] notificationMessage = toastMessage.getBytes();

url = new URL(subscriptionURI); //You must have the subscription URI provided by MPNS to client side.

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");

connection.setDoOutput(true);
connection.setRequestProperty("ContentLength", String.valueOf(notificationMessage.length));
connection.setRequestProperty("ContentType", "text/xml");
connection.addRequestProperty("X-WindowsPhone-Target", "toast");
connection.addRequestProperty("X-NotificationClass", "2");

connection.connect();

DataOutputStream out = 
    new DataOutputStream(
        connection.getOutputStream());
out.write(notificationMessage, 0, notificationMessage.length);
out.close();
Mon Apr 15 16:23:20 AST 2013
Answer #: 3
This answer has received: 0 Votes.

Yes you can send, but why should you send a push notification ? use live tile notification for that. use hubtile from Windows phone toolkit and add the Hub to the Visual tree, and do hubtile1.Notification ="Something you want to send as push notification";

Sat Jul 20 06:26:47 AST 2013
This question and its answers are found at: Sending Push notification to a Windows Phone 7 device?

XNA Phone 7: game locks up, no exception, but still ‘running’

This question has received: 0 Votes.

This is a weird one. The game does not exit, does not throw an exception as far as I can tell, but totally locks up (perhaps freezes is a better word). If there’s a way to trouble shoot this in VS I apparently don’t know what it is.

I’m looking far a general strategy: is there some tool in VS2010 where I can monitor this? Get some kind of output? Or perhaps a strategic spot to place a try/catch in the phone 7 game code?

I’m pretty much stuck, so any help would be much appreciated.

Fri May 27 12:36:41 AST 2011
Answer #: 1
This answer has received: 2 Votes.

When you have the debugger attached on the emulator or device and the lock up happens hit the pause button and see if there is a call stack.

Fri May 27 12:43:09 AST 2011
Answer #: 2
This answer has received: 1 Votes.

Upgrade to the beta of the Mango tools and then run the app through the (new, built in) profiler.

If you forcibly terminate the app once frozen you should be able to look at the profiler data to see what happens when it “locks up”.

Fri May 27 13:11:44 AST 2011
This question and its answers are found at: XNA Phone 7: game locks up, no exception, but still ‘running’

How to read individual lines of a text from the isolated storage?

This question has received: 0 Votes.

How to read each individual inputted text on their respective text block? When i activate the reading codes, they read the 2 text in 1 text block.

Saving Codes:

private void OnSaveFile(string filePath)
    {

        StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri(filePath, UriKind.Relative));

        using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
        {
            string directoryName = System.IO.Path.GetDirectoryName(filePath);
            if (!string.IsNullOrEmpty(directoryName) && !myIsolatedStorage.DirectoryExists(directoryName))
            {
                myIsolatedStorage.CreateDirectory(directoryName);
            }

            using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(filePath, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(fileStream))
                {


                    writer.WriteLine(text1);
                    writer.WriteLine(text2);


                }
            }
        }
    }

Reading Codes:

    private void OnReadSelected(string filePath)
        {

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists(filePath))
                {
                    using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(filePath, FileMode.Open, FileAccess.Read))
                    {
                        using (StreamReader reader = new StreamReader(fileStream))
                        {
                            this.textBlocky1.Text = reader.ReadLine();
                            this.textBlocky2.Text = reader.ReadLine();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Files are not Found!");

                }
            }
        }
Fri Jul 08 04:01:34 AST 2011
Answer #: 1
This answer has received: 2 Votes.

You are writing the text as a single line and then reading it as 2.

Instead of:

string someTextData = textFileName.Text + text1.Text;    
writer.WriteLine(someTextData);

you could do:

writer.WriteLine(textFileName.Text);   
writer.WriteLine(text1.Text);

Update
Here’s a working version:

assuming the page contains:

<TextBlock Text="item 1" />
<TextBox Name="textItem1" />
<TextBlock Text="item 2" />
<TextBox Name="textItem2" />
<Button Content="write" Click="WriteClick" />
<Button Content="read" Click="ReadClick" />

The following in the code behind will do what you want.

private void WriteClick(object sender, RoutedEventArgs e)
{
    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
    {
        using (var fileStream = store.OpenFile("myfile.txt", FileMode.Create, FileAccess.Write))
        {
            using (var writer = new StreamWriter(fileStream))
            {
                writer.WriteLine(textItem1.Text);
                writer.WriteLine(textItem2.Text);
            }
        }
    }
}

private void ReadClick(object sender, RoutedEventArgs e)
{
    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (store.FileExists("myfile.txt"))
        {
            using (var fileStream = store.OpenFile("myfile.txt", FileMode.Open, FileAccess.Read))
            {
                using (var reader = new StreamReader(fileStream))
                {
                    textItem1.Text = reader.ReadLine();
                    textItem2.Text = reader.ReadLine();
                }
            }
        }
    }
}
Fri Jul 08 14:39:56 AST 2011
Answer #: 2
This answer has received: 1 Votes.

While writing u insert a newline character \n in between the text which u want to be read as separate lines. The Readline() function reads till it encounters a newline character i.e \n. So whatever u want to be read as a separate line, insert a \n after that line.

Fri Jul 08 05:09:49 AST 2011
This question and its answers are found at: How to read individual lines of a text from the isolated storage?

Convert/Data binding, style textblock WP7

This question has received: 0 Votes.
   {
      "body": "testtt",
      "from_id": 37917395,
    },
    {
      "body": "hiii",
      "from_id": 124769733,
    },

I parse this response and need that messages from id “37917395” will be on left side of textblock, and messages from id “124769733” will be on right side.Like this:

testtt

     hiii

The messages may be not in order.Like this:

testtt

This also me

          hiii

I want to develop something like this :

sms view

I think I need to use Converter. Please help me with algorithm.

What I’ve already have. enter image description here

Mon Jul 11 09:42:04 AST 2011
Answer #: 1
This answer has received: 1 Votes.

I don’t think a converter alone will be enough.

Converters work on one value at a time and you need your example control to have knowledge of what the previous value (above it) was in order to change the alignment/grouping.

Best you change the type of data you are binding to. Parse the data first into a structure more suited to the display requirements. Include say a Left/Right alignment value as one of the properties. A converter would then be useful for converting that flag into an alignment.

Might be time for you to look at ViewModels 🙂

Mon Jul 11 09:56:15 AST 2011
Answer #: 2
This answer has received: 1 Votes.

You’ll need to determine if the from_id indicates if the message should be on the left or the right. You’ll then need to combine this with whatever method you are using to control whehter display is on the left or the right.

I’d assume you are making your own control to display the messages. I’d also assume that you have a property to indicate if it displays on the left or right of the screen. You should bind the from_id to this property and then use the converter to do the determining of if which side the message should be.

Mon Jul 11 10:08:22 AST 2011
Answer #: 3
This answer has received: 1 Votes.

if your data are put in a listbox, you need to use a DataTemplateSelector in the ItemTemplate of your listbox, with a first DataTemplate align left, and the other one align right. Just search a tutorial for DataTemplateSelector on WP7, it’s exactly what you need

Thu Nov 24 08:53:49 AST 2011
Answer #: 4
This answer has received: 0 Votes.

@wsevendays If each comment/record has a integer primary key then you could %2 that value (find the remainder when divided by two), which will either be 0 or 1 and use that to set a property to align the data in the UI to the left or right hand side.

Mon Jul 11 13:25:20 AST 2011
This question and its answers are found at: Convert/Data binding, style textblock WP7

How to create custom pin Start Button to my app?

This question has received: 0 Votes.

I want to create my custom pin Start Button to win phone 7.

For example in windows phone 7 i have the button of Marketplace pinned. When i receive update the pin button shows the number of updates i received. Another example is the calendar, when i create some appointment, these appears in pin button.

I want create something similar. I want a big pin button with some information. Any direction?

Mon Jul 11 10:15:11 AST 2011
Answer #: 1
This answer has received: 3 Votes.

The answer to this will probably depend on whether you are targeting Mango or not.

If you are targeting v 7, you will need to look into Notifications. This MSDN article will give you some good information as a starting point.

In Mango (7.1) you can accomplish a lot more manipulation of tiles from inside your app. This MSDN article is a great start point for that.

Please note, however, that your user will need to have the application tile pinned in order to get the behaviour you are describing.

Mon Jul 11 10:18:06 AST 2011
This question and its answers are found at: How to create custom pin Start Button to my app?

Stop back button during data pull?

This question has received: 0 Votes.

Is it possible to stop the back button from working during a data call? For instance, when registering, I don’t want someone to press the back button otherwise they may register for my service and not know it (other than confirmation email)? (And the registration will fail the next time they try)

Fri Jul 15 15:26:30 AST 2011
Answer #: 1
This answer has received: 2 Votes.

Handle the BackKeyPress event or override the OnBackKeyPress method in your page class, and then set e.Handled = true; when you want to prevent backwards navigation.

Note that if you do this, then you should provide the user with a way to cancel your long-running process so they can back out if they want to.

Fri Jul 15 15:36:43 AST 2011
Answer #: 2
This answer has received: 1 Votes.

Please note that if you stop the Back button from working your application will fail marketplace submission.

See section 5.2.4 Use of Back Button.

If a user has the situation where they try to reregister (becuase they don’t realise they have registered previously) then you should handle this in your app as the situation may come up anyway.

Fri Jul 15 20:44:50 AST 2011
This question and its answers are found at: Stop back button during data pull?

ApplicationBarIconButton Click Event Crash

This question has received: 0 Votes.

I’m not sure what’s wrong/what I’m missing but I get the following error:

“AG_E_PARSER_BAD_PROPERTY_VALUE”

Whenever I add a “Click=” to my xaml for the application bar.

I have this code currently:

<shell:ApplicationBarIconButton IconUri="/Resources/Icons/ApplicationBar.Settings.png" Text="Settings" Click="Settings_Click"/>

The method Settings_Click exists, beyond that, I’m not sure what I’m missing?

Fri Jul 15 20:29:05 AST 2011
Answer #: 1
This answer has received: 1 Votes.

Are you sure the method has the right signature?

void Settings_Click(object sender, EventArgs e) { }
Fri Jul 15 20:41:22 AST 2011
Answer #: 2
This answer has received: 2 Votes.

My Advice: If you always give your buttons a name and let visual studio intellisence to create handler methods this never happens:

<shell:ApplicationBarIconButton x:Name="btnSettings" IconUri="..." Text="Settings" 
         Click="[let intellisence complete this]"/>
Fri Jul 15 20:55:08 AST 2011
This question and its answers are found at: ApplicationBarIconButton Click Event Crash