[IOS/Android] Local Notifications [v2.5.3]

robinschaafsma

  • *
  • Posts: 714
Local Notifications
Works on iOS, Android


HOW TO
Go to https://byrobingames.github.io

OPENSOURCE

Submitting a Pull Request
This software is opensource.
If you want to contribute you can make a pull request

Repository: https://github.com/byrobingames/localnotifications

Need help with a pull request?
https://help.github.com/articles/creating-a-pull-request/

ANY ISSUES?
Creating an issue on GitHub
Repository: https://github.com/byrobingames/localnotifications/issues

Need help with creating a issue?
https://help.github.com/articles/creating-an-issue/

« Last Edit: December 30, 2018, 07:46:52 am by robinschaafsma »


This is great! Thank you so much!

GameDev408

  • Posts: 257
This is a great extension!

mdotedot

  • Posts: 1654
Hi Robin,

Very Cool!

As you mentioned it doesn't work when app is closed on Android.

Do I have your permission to modify the code a bit and try to see if I can let it work with my server?!

Thanks a lot for your work! Appreciated!

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

robinschaafsma

  • *
  • Posts: 714
Hi Robin,

Very Cool!

As you mentioned it doesn't work when app is closed on Android.

Do I have your permission to modify the code a bit and try to see if I can let it work with my server?!

Thanks a lot for your work! Appreciated!

Best regards from
M.E.


Yes you have, if you have a solution, let me know.

mdotedot

  • Posts: 1654

Hallo Robin,


In NCReceiver you try to access Extension.mainActivity .. it is null!
Code: [Select]

//        Intent notificationIntent = new Intent(context, Extension.mainActivity.getClass());

//        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);


Replace above with this:

Code: [Select]

        PendingIntent contentIntent= PendingIntent.getActivity(context.getApplicationContext(), 0, new Intent(), 0);


So we create a new Intent.

Rest works fine!

For the iOS I needed to change something as well to make it work on < iOS 8 … Everything works nicely on iOS 8.1.2 but failed on my older devices.

Code: [Select]
// [self setNotificationTypesAllowed];


And to let the <ios8 do actually something I assume allowNotif so I commented out those things:
Code: [Select]
    //if (allowNotif)

    //{


//}



So now I can try to connect to my server and display messages that I need to say to the user.

On Android/Java I think I can manage to not raise the notification but keep it repeating.
Do you have a trick I could use to do the same in iOS?
What I want is to check on notification for something on a server and depending on
the result raise the actual notification or omit the notification and check the server in the repeated - setting.

Best regards/
Vriendelijke groet!

M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

robinschaafsma

  • *
  • Posts: 714
Hi M.E.

Thanks a lot for your solutions, i have updated the extension.

Quote
On Android/Java I think I can manage to not raise the notification but keep it repeating.
Do you have a trick I could use to do the same in iOS?
What I want is to check on notification for something on a server and depending on
the result raise the actual notification or omit the notification and check the server in the repeated - setting.

No, sorry don't know a trick for that.

mdotedot

  • Posts: 1654

Hoi Robin,


The AndroidManifest.xml contains SMS permission.
Why did you turn that on?
I've removed the permission and the app seems to work fine without it.
Code: [Select]
  <uses-permission android:name="android.permission.SEND_SMS"/>


I played a little with private subclassing your NCReceiver to make the notification fire when a reponse is received from an online server. 
That appears to work in my test situation for Android. I'm about to test/play with iOS to do the same.

Do you mind if I made a new extension based of your work? I want to notify gamers with invites from other players to join a game or send gamers other information from my server!


Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

robinschaafsma

  • *
  • Posts: 714
Quote
The AndroidManifest.xml contains SMS permission.
Why did you turn that on?

I tested notification with SMS, forgot to delete it.

Quote
Do you mind if I made a new extension based of your work? I want to notify gamers with invites from other players to join a game or send gamers other information from my server!

Do you mean like Push notification extension?
Than you can make a Push notification extension based of my work. But make it for Android and IOS.
I have a lot of work at it.
If this extension works good, maybe we wanna build it in Stencyl.

mdotedot

  • Posts: 1654
Remote / Push notification was not exactly what I was going for.
From what I've seen the mechanism would involve a lot of tweaks to get right.

What I've discovered so far is that iOS doesn't really allow background applications to become active easily.
There are some things that I'm exploring but it isn't as easy as Android was. What Apple seems to want you to do is to go for remote notification.

I don't actually understand what you said about a ' lot of work at it'

Wat bedoel je precies? Heb je er al veel tijd ingestoken of was je van plan er tijd in te stoppen?

Best regards from
Vriendelijke groet,
M.E.

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

robinschaafsma

  • *
  • Posts: 714
Quote
Wat bedoel je precies? Heb je er al veel tijd ingestoken of was je van plan er tijd in te stoppen?

I just see now, you are dutch also, sorry for my bad english :)

Ik bedoel dat ik er veel tijd in de extension heb gestoken, en daarom dat je op basis van mijn werk een nieuwe extension mag maken.

iOS have lots of roles, i think what you wanna do, only possible with Push Notificaton or Game Center Multiplayer methode. But i am not sure.

Best regards from
Vriendelijke groet,
Robin.

robinschaafsma

  • *
  • Posts: 714
UPDATE 2.3
-Download from GitHub

See the first post, you have to download it from GitHub now.

If you already install a previous version 2.2 or below,  follow the instruction on this page how to update the extension https://github.com/byrobingames/localnotifications/blob/master/README.md#how-to-install

designpeg

  • Posts: 731
I get the following error

[openfl] Error: Could not find asset path /STENCYL_DEVELOPMENT/stencylworks/engine-extensions/localnotifications/assets/"

robinschaafsma

  • *
  • Posts: 714
I get the following error

[openfl] Error: Could not find asset path /STENCYL_DEVELOPMENT/stencylworks/engine-extensions/localnotifications/assets/"

Oops, can you download version 2.4 from github and reinstall the extension. let me know when this resolved the problem