Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Parse SDK in Windows 10 Universal App #63

Closed
techievbv opened this issue Nov 5, 2015 · 44 comments
Closed

Using Parse SDK in Windows 10 Universal App #63

techievbv opened this issue Nov 5, 2015 · 44 comments

Comments

@techievbv
Copy link

Hi, we are working on Windows 10 Universal app and trying to integrate Parse push notifications functionality. We have tried both v1.6.0 and 1.5.5 of Parse SDK to subscribe to a channel using installation.SaveAsync() or using shorthand like SubscribeAsync() , but, the device is not getting registered (i.e. not subscribing to the channel on Parse portal Installation table). Kindly , let us know if there is a fix available for it.

@Julien-Mialon
Copy link
Contributor

Hello,
I added support for W10, you can check it there : https://github.com/Julien-Mialon/Parse-SDK-dotNET

@SalehAlbuga
Copy link

Same here but it keeps throwing System.Aggregate exception

@techievbv
Copy link
Author

@Julien-Mialon we are unable to Build the Parse.UWP project in VS 2015. Errors show HttpClient,Httprequest, etc. not accessible due to its protection level. Please check from your side and Suggest what we can do from our side. Thanks.

@Julien-Mialon
Copy link
Contributor

@Vaibhavmalik3122 are you using the Parse nuget ? If yes, you should use the Parse source code directly. There is a small modification on Parse code in order to Parse.UWP use the internal types.

@techievbv
Copy link
Author

@Julien-Mialon @richardjrossiii we are able to build our project using the Parse.UWP reference , and sucessfully registered the username in the Installation table. But, when trying to send a Test push notification via Parse push portal, it is NOT able to send on the Windows 10 device.

@richardjrossiii
Copy link
Contributor

@Vaibhavmalik3122 Yep, that sounds par for the course. Our backend does not currently support UWP push, and won't until we 'officially' support the UWP version of the SDK in an official capacity, sadly.

@Julien-Mialon
Copy link
Contributor

@Vaibhavmalik3122 : that sound weird, I'm currently using it with an UWP app without any issues, push notifications work great. It uses the same system than WinRT app.

@techievbv
Copy link
Author

@Julien-Mialon could you please elaborate what small modifications on parse code were you talking about for Parse.UWP to use internal types in previous comments ?

@Julien-Mialon
Copy link
Contributor

@Vaibhavmalik3122 : you can check my commit for uwp support there : Julien-Mialon@d6ac21a
Basically, modification in Parse code was in ParseClient.cs to add Parse.UWP to assembly list to use when looking for implementation of interfaces and in AssemblyInfo.Portable.cs add this line [assembly: InternalsVisibleTo("Parse.UWP")] to authorize Parse.UWP project to access internal types of Parse project.

@mehul9595
Copy link

@Julien-Mialon Could you provide sample solution to use Parse.UWP solution? I tried to use it by creating new UWP project and referencing the library. On app launch adding this line "await ParsePush.SubscribeAsync("");". But it throwing exception Unable to cast object of type 'Parse.ParseObject' to type 'Parse.ParseInstallation'. please help.

@techievbv
Copy link
Author

screenshot 90
@Julien-Mialon we have the latest pull of the repository and hence all the modifications you talked about are already there(check the screenshot attached).But still we are not able to send push Notifications from parse dashboard. We need to complete this as our official project deadline is coming to an end soon . Would really appreciate if you could assist us on this, maybe a skype call or teamviewer session would help. Looking forward.

@mehul9595
Copy link

I was able to fix cast exception by referencing Parse.dll and initializing ParseClient.Initialize("key", "key") method. But still no luck with push notifications from Parse console :(

@Julien-Mialon
Copy link
Contributor

I just tested this procedure, tell me if it works for you. Otherwise, we can plan teamviewer or skype session to debug that issue.

  • create vs project UWP W10
    01-project_creation
  • clone parsesdk github from my profile (with modification for UWP)
  • copy Parse & Parse.UWP directory in your project directory
    02-sdkcopy
  • right click your solution in vs2015 and import project Parse/Parse.csproj and Parse.UWP/Parse.UWP.csproj
  • Check that reference to Parse in Parse.UWP is correct
  • Add Parse and Parse.UWP in your app reference
    03-parseinstall
  • Check if everything build correctly
  • Go to dev.windows.com
  • Create a new app by reserving its name.
  • In my test it will be called "storeTestingStorm"
  • Look at your app overview and go to section "Services"/"Push notifications"
    04-storeinfo
  • Click on link "Live Services site"
  • Copy package SID & client secret to parse configuration page
    05-sid_clientsecret
  • Go to parse.com and create an app (I called it "testParseUWP")
  • Go to push section and scroll down to "Windows Push Credentials". Paste your app SID and client secret
    06-parseconfig
  • Go to keys section and copy "Application Id" & ".NET Key"
    07-parsekeys
  • Let's go back in VS 2015
  • right click on your app and associate it with your store app (store -> associate app with the store...)
  • In your app.xaml.cs constructor, add "ParseClient.Initialize(APPLICATION_ID, .NET_KEY)" where APPLICATION_ID and .NET_KEY are values from parse keys page.
  • Add "ParseInstallation.CurrentInstallation.SaveAsync();" just after this line
  • Launch your app and suspend it via "Lifecycle events" in VS toolbar (if not available, right click on VS top toolbar and enable "Debug Location") Do not stop the app
    08-lifecycle
  • Go back to parse.com and send a push notification
  • If everything went fine, it shows a push notification on your desktop after a few seconds

@lukaszkalnik
Copy link

Great guide, thank you @Julien-Mialon! I have made only a small modification: I'm calling await ParseInstallation.CurrentInstallation.SaveAsync(); in async onLaunched() (and not in constructor), as it's an asynchronous method.

@mehul9595
Copy link

@Julien-Mialon Thanks for steps!
As from the steps you mentioned, I was not doing "ParseInstallation.CurrentInstallation.SaveAsync();"
but I will try with this change and see if it works. Thanks again!

@lukaszkalnik
Copy link

Although right now I have the (small) problem that the push opens don't get tracked in Parse.com (only push sends - I see e.g. 2 pushes sent and 0 opened).

My code looks like this:

    public App()
    {
 (...)
        ParseClient.Initialize(app_id, app_key);
    }

(...)

    protected override async void OnLaunched(LaunchActivatedEventArgs e)
    {
(...)
        await ParseInstallation.CurrentInstallation.SaveAsync();

        // By convention, the empty string is considered a "Broadcast" channel
        // Note that we had to add "async" to the OnLaunched definition to use the await keyword
        await ParsePush.SubscribeAsync("");

        // Track this application being launched
        await ParseAnalytics.TrackAppOpenedAsync(e);
    }

Any suggestions?

Thanks so much!

@mehul9595
Copy link

I tried with above steps but still cannot send push successfully, this is what i see on Parse dashboard
image

[Update]
I was having incorrect package manifest file, associating with store again, it solved.
Thanks

@Julien-Mialon
Copy link
Contributor

@lukaszkalnik @mehul9595 about the opened notification count, it's an issue from Parse. I just tried with the WinRT sdk (nuget 1.7.0), it doesn't work either. The sdk expect to receive a json with "push_hash" field to track push notification open count. And this field is not sent by Parse backend, just receiving something like {"alert":"push notification message"}

@lukaszkalnik
Copy link

@Julien-Mialon cool, thanks so much for the information! You are really helping a lot, I appreciate it!

@Julien-Mialon
Copy link
Contributor

@lukaszkalnik I just opened a dedicated issue (#162) for the problem with the missing field in json notification.

@techievbv
Copy link
Author

@Julien-Mialon Notifications are working good. Thanks for the steps. But, one issue is bugging us , whenever the app is in Foreground state , the toast notification banner does not appear , even after the app is closed , no notification appears in Action center. The ParsePush.PushNotificationReceived is hit everytime , but on the OS level no notification shows up.

@Julien-Mialon
Copy link
Contributor

@Vaibhavmalik3122 I just tested foreground notifications and it works without issue, can you check with the project available there : https://github.com/Julien-Mialon/Parse.UWP.Sample, you just have to associate the app with the store and write your Parse appid and .net key in Constants.cs.

If it's doesn't work for you, check if in the event handler of PushNotificationReceived, args.NotificationType == "Toast" and args.Cancel is not set to true.

@michstmatt
Copy link

@Julien-Mialon I followed your steps, the app has been associated with the store, and I had it working in December, now it is randomly not working (I had not tested it for some time because I had got it working). Do you have any more suggestions?

@Julien-Mialon
Copy link
Contributor

@michstmatt If it's randomly working, I can not really think of something from the app that can block this. But I saw some issue from Windows notification service working sometimes.

@mehul9595
Copy link

@Julien-Mialon I was wondering if its possible to send 'adaptive toast notificatoins' which are supported by win10 adaptive templates (ref: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/08/toast-notification-and-action-center-overview-for-windows-10.aspx)
As I can see from Parse dashboard it only allows to send Plain Text or Json data into Push notification. Is there additional things needs to be done in order to these custom push notifications?

@Julien-Mialon
Copy link
Contributor

@mehul9595 Not supported for now but I think there is another opened issue about that. #137

@mehul9595
Copy link

@Julien-Mialon well exactly what I was looking for. thanks again!

@michstmatt
Copy link

@Julien-Mialon I created a new project, I found out that when I copy the Package SID its adds a blank character at the end. Went back into my original projects parse push settings, sure enough blank character at the end, fixed it and its working. Thanks for making this library!

@mehul9595
Copy link

@Julien-Mialon is it possible to send push notification with deeplink? if yes, how can it be handled?

@Julien-Mialon
Copy link
Contributor

@mehul9595 I think you can do that by sending json content in your notification and then parsing this content in your application. You can embed deeplink info in this json.

@Julien-Mialon
Copy link
Contributor

@lukaszkalnik @mehul9595 I just implemented support to track opened notification count in WinRT & winPhone (#164) and did the same modification on my uwp fork you can find here : https://github.com/Julien-Mialon/Parse-SDK-dotNET/tree/features/uwpSupport

@lukaszkalnik
Copy link

Thanks @Julien-Mialon, I have just tested the opened pushes reporting and it works flawlessly. Great job!

The only weird thing is that now I get an error when starting the Release build on a Windows 10 Mobile device:
0x76CCE031 (combase.dll) in ApplicationName.exe: 0xC000027B: An application-internal exception has occurred (Parameter: 0x038E60F8, 0x00000002).
When I start a Debug build though everything is working correctly.

On a Windows 10 PC both Debug and Release builds are working correctly.

@lukaszkalnik
Copy link

Hmm, I just checked and with your previous version of the SDK I have actually the same problem (Release build not working on a smartphone). Probably this is unrelated to your changes then.

Thanks for your awesome help!

@SalehAlbuga
Copy link

@Julien-Mialon Thank you, great job! I have a problem with receiving push notifications. After implementing ParsePush.ParsePushNotificationReceived, Parse.UWP throws System.NullReferenceException when the app receives a notification

@Julien-Mialon
Copy link
Contributor

@SamAlbuga I think you have to subscribe to 2 event, ParsePushNotificationReceived and PushNotificationReceived.

@mehul9595
Copy link

@Julien-Mialon is it under master yet? which branch do you suggest to use?

@Julien-Mialon
Copy link
Contributor

For uwp, you can use the branch "features/uwpSupport" on my repo. Not merged with official parse repo for now. https://github.com/Julien-Mialon/Parse-SDK-dotNET

@mehul9595
Copy link

cool, I was using master branch from your repo so far working fine for me without issues. I will change to your feature branch.

@SalehAlbuga
Copy link

@Julien-Mialon Yes that worked perfectly. Thank you :)

@techievbv
Copy link
Author

Hey @Julien-Mialon , when app is in foreground, how can we create a custom toast notif. for the user such that, when clicked, a custom event can be hit instead of Onlaunched. for reference , WhatsApp for WP is a good example.

@mehul9595
Copy link

@Vaibhavmalik3122 I don't think if that's possible, seems it is an part of enhancement, 137 . Once interactive notifications is supported this can be achieved.

@mehul9595
Copy link

I found a case where push notification is sent during device is power off, notifications are not delivered on tablet device when tablet is powered on.
On Windows phone, push notification is seen when device is powered on.
Any clue?

@lukaszkalnik
Copy link

@Julien-Mialon we are currently testing and turns out I cannot start the app with Parse SDK in Release mode on a Lumia 930 phone. It starts in Debug mode though... I get the following exception:
Exception at 0x777AE031 (combase.dll) in App.exe: 0xC000027B: An application-internal exception has occurred (Parameter: 0x00894FC8, 0x00000002)

update it happens on the ParseClient.Initialize call

@TobiasPott
Copy link
Member

Based on the latest version in the master branch using the Parse SDK on UWP platforms does work.
If any specific problem re-occurs with the latest version from the master branch, feel free to create a new issue to discuss possible solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants