Question: I am trying to send Push Messages from the server to my iOS device.

The application is receiving messages (only in foreground) when I am sending the following JSON message -

```
{
  "to": "<my_reg_id>",
  "data": 
    {
      "body": "Hello world",
      "title": "Title"
    }
}

```

However, when I am sending messages in the format given on [Setting up a GCM Client App on iOS](https://developers.google.com/cloud-messaging/ios/client) (given below), I am getting `"error": "InternalServerError"` in the server response -

```
{
  "to": "<my_reg_id>",
  "content_available": true,
  "priority": "high",
  "notification":
    {
      "body": "Hello world",
      "title": "Title"
    }
}

```

Can anybody tell me what to do about this ? I really need to receive background notifications for my app.

(P.S. - I have enabled Remote Notification and Push Notification Capabilities in xCode for my app.)

Answer: 
You should do it like this:

```
@foreach (var item in Model
                     .Select(x => new //here you count your total
                     { 
                         Rid = x.Rid, 
                         Total = x.Total * x.Quantity
                     })
                     .GroupBy(l => l.Rid) //and then grouping
                     .Select(z => new 
                     { 
                         Turno = z.Key, 
                         Total = z.Sum(l => l.Total) 
                     }))
{
   <input value="@item" />
}

```
*I want to get a result in wich the Quantity is multiply by the Total and by that sum all totals for all diferent "**Pdv**" and "**Rid**"*

```
@foreach (var item in Model
                     .Select(m => new { Rid = m.Rid, m.Pdv, Total =m.Total * m.Quantity})
                     .GroupBy(g => new { g.Rid, g.Pdv} )
                     .Select(s => new 
                     { 
                         Rid = s.Key.Rid, 
                         Pdv = s.Key.Pdv, 
                         Total = s.Sum(t => t.Total) 
                     }))
{
   <input value="@item" />
}

```