Fork me on GitHub
#cljsrn
<
2017-05-03
>
rc114004:05:24

cross posting from re-frame since i was told i might have better luck here

rc114004:05:40

hi all , does anyone here know how to implement the android part of this react-native-plugin (https://github.com/zo0r/react-native-push-notification ) in re-frame i have seen a bunch of examples that all only seem to implement the iOS part i cant see how to implement the class override specifically i know it mentions only if i did not use the link command manually , just not sure if that applies to re-frame or not, referring to this statement [Manually register module in MainApplication.java (if you did not use react-native link)]

vikeri17:05:07

@rc1140 We're using it and just using normal interop works well for us. Maybe you could share your code?

rc114018:05:37

@vikeri hi , will try and get it uploaded now , but i didnt do much aside from create a new re-natal project and follow the instructions on the repo page

rc114018:05:53

i think it may be related to the version of the google play gcm lib , but im not sure what version i should be using

benny18:05:07

the https://github.com/zo0r/react-native-push-notification#android-manual-installation section seems to pretty clearly document how to add Android support. Are you getting an error of some sort or a specific question about how to make the changes to the Android project?

rc114018:05:06

so i manually checked the MainApplication.java file and the required imports etc are there

rc114018:05:38

but the anon function for registration of a token never fires

rc114018:05:26

and calling (.localNotification push-notification {params here}) to test it fails as well with , can not read property call null of undefined

rc114018:05:01

which from what i understand means the location notification call is not working

rc114018:05:31

used this as an exmaple on how to do the configuration

benny18:05:13

did you call re-natal use-component after adding react-native-push-notification?

rc114018:05:17

(from my history) , re-natal use-component react-native-push-notification

rc114018:05:34

as far as i can tell there is no component part

benny18:05:00

looks like you didn’t include the com.google.android.gms:play-services-gcm dependency

rc114018:05:14

i did as well , but thats what i was asking about earlier

rc114018:05:17

regarding the version

rc114018:05:26

in the docs they use 8.1.0 i think

rc114018:05:33

i dont know if thats old

rc114018:05:40

thats not my app sorry

rc114018:05:46

let me just push my code

benny18:05:50

you should stick with the same google services version

rc114018:05:54

sorry for the delay

rc114018:05:01

ok then i have that in place

benny18:05:02

9.4.0 if it’s the same as the linked gradle

benny18:05:13

yeah your latest code would be best, looks like AndroidManifest.xml is missing some stuff too but not sure if you have it locally?

rc114018:05:25

yeah i added that

rc114018:05:31

basically followed the readme

rc114019:05:11

let me know if you spot anything

benny19:05:49

just glanced through all the android configuration and it seems fine

benny19:05:23

if you re-build with figwheel, you don’t see any errors?

rc114019:05:25

but that never fires

rc114019:05:31

no errors sadly 😞

rc114019:05:51

initialy i was getting errors because of not having the use-component part

benny19:05:52

but you see setting up notifications?

rc114019:05:07

after that its a dump of the push-notification object

rc114019:05:35

setting up notifications
figwheel-bridge.js:172 #js {:handler #object[NotificationsComponent [object Object]], :onRegister #object[Function "function (token){
return cljs.core.println.call(null,token);

rc114019:05:52

obviously snipped for verbosity

benny19:05:58

I wonder if you need this

benny19:05:35

(def push-notification (.-default (js/require "react-native-push-notification")))
or
(def push-notification (.-PushNotification (js/require "react-native-push-notification")))

rc114019:05:02

let me try quickly if you dont mind waiting a bit

benny19:05:10

I’ll be here all day 😉

benny19:05:40

if neither one of those work, try .-Notifications

rc114019:05:44

second option got , Cannot read property 'configure' of undefined

benny19:05:09

i have my money on .-Notifications

rc114019:05:58

nope none of the options worked in that they all return a null object

rc114019:05:06

which causes the configure to fail to run

benny19:05:32

it’s weird that it’s just printing

benny19:05:04

i’ll have to take a look again in a bit

rc114019:05:16

its driving me insane 😞 , should be so simple

rc114019:05:54

btw this is the full dump of the println of the push-notification

benny19:05:56

yeah, you had it right first, i didn’t catch that it was actually calling your onRegister

rc114019:05:10

its not calling the onRegister

rc114019:05:22

the println im talking about is from later in the code

rc114019:05:58

that output comes form line 41

benny19:05:25

onRegister is false in your printout… :thinking_face:

rc114019:05:10

there is a _onRegister late

benny19:05:05

that’s not the one you’re trying to set though

rc114019:05:22

shrug i am honestly not sure

benny19:05:27

that’s the internal _onRegister that calls yours if it’s set

benny19:05:35

for some reason your call isn’t registering first

benny19:05:23

the ideal solution would be to include your configure in a re-frame effect i would think

rc114019:05:44

surely at this point thats just semantics

rc114019:05:00

as in the call doesnt seem to be working as expected

benny19:05:01

the effect part? yes mostly

rc114019:05:05

so where it is wont help

benny19:05:15

but it seems like you might be at least observing a race

rc114019:05:50

gonna wait on @vikeri at this point , im pretty KO and not getting this working is just frustrating

benny19:05:37

yeah i’m interested to find out what’s going on

benny19:05:08

one last suspicious piece is that you’re importing a mutable js object and i’m just not sure how that ends up translating

rc114019:05:25

also every example has been demonstrated using ios , really wonder if it even works with android

rc114019:05:34

yeah not sure about that at all

rc114019:05:31

anyway thanks for all the help

vikeri19:05:16

`(defonce Notification (js/require "react-native-push-notification"))`

benny19:05:36

[/giphy ahhhhh]

vikeri19:05:51

And (defn dispatch-notification! [body] (.localNotification Notification (clj->js body)))

vikeri19:05:11

Is what we're doing. Sorry for the formatting. I'm on mobile

benny19:05:38

I’m going to need to do this soon too so thanks @vikeri

vikeri19:05:46

@benny I can't say my contribution was substantial but if it worked then great 😉

benny19:05:52

i should have known to use defonce but i’m assuming knowing what i do that could get @rc1140 what he needs