Habeeb
Habeeb

Reputation: 1040

Azure mobile service to sent push notification to specific IOS user

I am able to send push notification to all the devices with below code

   ApplePushMessage message = new ApplePushMessage("Item : "+ item.Name+ " Saved", System.TimeSpan.FromHours(1));

        try
        {
                var result = await Services.Push.SendAsync(message);
                Services.Log.Info(result.State.ToString());

        }
        catch (System.Exception ex)
        {
            Services.Log.Error(ex.Message, null, "Push.SendAsync Error");
        }

I need to sent to specific user using device token.

I found the code with node.js. But with .net i am not able to send only to the specific user.

// Get the ID of the logged-in user.
var userId = user.userId;

function insert(item, user, request) {
    request.execute();
    setTimeout(function() {
        push.apns.send(userId, {
            alert: "Alert: " + item.text,
            payload: {
                "Hey, a new item arrived: '" + item.text + "'"
            }
        });
    }, 2500);
}

Is there any equivalent code method in Dotnet. Or can i have to user tags instead of device token?

Thanks in Advance.

Upvotes: 0

Views: 276

Answers (1)

Alex Belotserkovskiy
Alex Belotserkovskiy

Reputation: 4062

Yes, the tag is the better approach, i believe. We use that and it works perfectly.

https://msdn.microsoft.com/en-us/library/azure/dn530749.aspx - guidance

https://msdn.microsoft.com/en-us/library/azure/dn530749.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-3 - some code.


If that is the helpful answer, please mark it as a helpful or as the answer. Thanks!

Upvotes: 3

Related Questions