-
Notifications
You must be signed in to change notification settings - Fork 42
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
TnsOneSignal.initWithLaunchOptionsAppId is not a function #65
Comments
Yes same issues, searched for answers and no luck, hope the solution is provided here: |
@elconix I am still looking for a way to implement it. Have you found anything what works? I am on the half way to implement this https://documentation.onesignal.com/docs/ios-sdk-setup as native (if possible). Having trouble adding last piece of puzzle from Step 5 - Add the OneSignal Initialization Code If anyone knows where and how to add this, it would help a lot. Thc |
Hello @markosole all nativescript plugins suffer the same thing, so mark this will be a new plugin? |
@elconix Code below works - I can see phone registering on OneSignal. There is one minor problem, OneSignal shows Other Apns 3000 error which I have to fix. That should not be a problem. My code:
What I have noticed, OneSignal have changed the way of accepting parameters, therefore There are some more added there as iOS 13+ requires that. Check screenshot below. As said before, functions can be added and I will fork to and add those changes once I solve APN problem. EDIT; for your previous question - if you migrated your project to NS7 (which I believe you had to if want to publish for ios 14) than all plugins must be updated. It took me a week to get it all sorted (the ones I am using). Let's fix OneSignal first and I will try to help with others if can. |
Wow @markosole awsome news, so steps: |
You are correct, go give it a try :)
I am working on APN 3000 error. You try and let me know how it goes for you. |
@markosole I use pure js, so it will be this code you attached right? |
Just for your refference:
I suppose it initialize ok. |
OK no the next step is to get the person id, for that in my login procedure I added this code:
Got this in console: Is there a new way to get the person id, or is not yet implemented? O need to update the onesignal-plugin? |
Just as a good sign, I do see the Iphone Simulator in the Onesignal dashboard. |
Ok @markosole worked to compile well in ios, change my old code to:
the only issue now is that this code does not work for android and also the TnsOneSignal.getPermissionSubscriptionState does not work. |
Do i need to change something in android? the error in android now is: |
Yeah but what does it say? "Never Prompted" or all looks okey? - I am getting this "Never Prompted" message and still trying to solve it.
Android should be fine, no need to change anything. To be honest I have not try yet and iOS gives trouble. |
@elconix Good news again; Here is final example which works and Device is receiving push notifications properly. No fancy stuff haven't been added, you can check out links in comments for more details and available parameters. I can help with implementing them. As you already probably know, you have to enable background notifications in Xcode project.
For the reference, here are typings available in this nativescript plugin: https://github.com/roblav96/nativescript-onesignal/blob/master/typings/OneSignal.ios.d.ts Check the line starting with declare class OneSignal extends NSObject { What ever is available here: https://documentation.onesignal.com/docs/ios-native-sdk may not be available in OneSignal.ios.d.ts. OneSignal has updated Parameter list and names, implementation as well. Forked version: https://github.com/markosole/nativescript-onesignal |
this works with android @markosole have you tested in both platforms? |
Ok @markosole reinstalled the plugin as the link https://github.com/markosole/nativescript-onesignal Android does not work, used the documentation you have in the link: https://github.com/markosole/nativescript-onesignal and it sends the following error when asking for the same code working in ios for person id: System.err: TypeError: TnsOneSignal.getDeviceState is not a function Let me know how your android compilation works out. Thanks |
THis is my code for getting person id:
Ios working, android sending the error: |
Ok @markosole awsome, IOS finally working in device and everything ok. Only now the android issue, did you try it? Thanks |
What issue you have? Example for Android I've posted works fine. I see you are using getDeviceState, there is something different for getting state. I will have a look into one of mine older projects. Let me know If you still have problem with it. |
@elconix Here is android sample (I haven't tested for a year or so) which should work. The part you need is The parameter/class/function
Device state or subscription status, what exactly u need? |
Ok tried this code, but it only got to Android 1:
if (application.android) {
console.log("Android 1") ;
application.on(application.launchEvent, function (args) {
try {
//console.log('TnsOneSignal', TnsOneSignal);
if (appSetting.NotificationsEnabled()) {
TnsOneSignal.startInit(application.android.context).init();
TnsOneSignal.setSubscription(true);
// ID OneSignal
var status = TnsOneSignal.getPermissionSubscriptionState();
console.log("Andoid push ID: " +
status.getSubscriptionStatus().getUserId());
formData.append('onesignal_id', status.getSubscriptionStatus().getUserId());
// do something with status ID
console.log("Android 2") ;
} else {
TnsOneSignal.startInit(application.android.context).init();
TnsOneSignal.setSubscription(false);
console.log("Android 3") ;
}
// Sunscribe
// # TnsOneSignal.startInit(application.android.context).init();
} catch (error) {
console.log('error', error);
}
})
}
This is android.
El vie, 8 ene 2021 a las 22:04, Marko Solomun (<[email protected]>)
escribió:
… @elconix <https://github.com/elconix> Here is android sample (I haven't
tested for a year or so) which should give you what you need
`
var TnsOneSignal = require("nativescript-onesignal").TnsOneSignal;
if (application.android) {
application.on(application.launchEvent, function (args) {
try {
//console.log('TnsOneSignal', TnsOneSignal);
if (appSetting.NotificationsEnabled()) {
TnsOneSignal.startInit(application.android.context).init();
TnsOneSignal.setSubscription(true);
// ID OneSignal
var status = TnsOneSignal.getPermissionSubscriptionState();
console.log("Andoid push ID: " + status.getSubscriptionStatus().getUserId());
// do something with status ID
} else {
TnsOneSignal.startInit(application.android.context).init();
TnsOneSignal.setSubscription(false);
}
// Sunscribe
// # TnsOneSignal.startInit(application.android.context).init();
} catch (error) {
console.log('error', error);
}
})
}
`
Device state or subscription status, what exactly u need?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASKWDX2U4U35KO4RF2PMSXDSY7BUZANCNFSM4U4MRKOA>
.
|
Sorry for late reply, I will test it ASAP when get chance. For now, remove appSetting.NotificationsEnabled() part as that's something what I built in for checking phone settings and opt-in / out option. You can replace it with if(1==1).... just for test. |
Thanks I will wait, as I have a apk working before the ios changes,
Thanks
…On Sun, Jan 10, 2021 at 6:37 PM Marko Solomun ***@***.***> wrote:
Sorry for late reply, I will test it ASAP when get chance. For now, remove
appSetting.NotificationsEnabled() part as that's something what I built in
for checking phone settings and opt-in / out option. You can replace it
with if(1==1).... just for test.
I'll fire up my PC in 2-3 days and test on Android. @elconix
<https://github.com/elconix>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASKWDX2GJLTFUT77Q5WXNH3SZI25FANCNFSM4U4MRKOA>
.
|
Hello Marko any news about android?
…On Sun, Jan 10, 2021 at 6:43 PM Moises Vega ***@***.***> wrote:
Thanks I will wait, as I have a apk working before the ios changes,
Thanks
On Sun, Jan 10, 2021 at 6:37 PM Marko Solomun ***@***.***>
wrote:
> Sorry for late reply, I will test it ASAP when get chance. For now,
> remove appSetting.NotificationsEnabled() part as that's something what I
> built in for checking phone settings and opt-in / out option. You can
> replace it with if(1==1).... just for test.
> I'll fire up my PC in 2-3 days and test on Android. @elconix
> <https://github.com/elconix>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#65 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ASKWDX2GJLTFUT77Q5WXNH3SZI25FANCNFSM4U4MRKOA>
> .
>
|
Hi @elconix sorry I did not have time to try it. It's def on my list to do as I have to update android versions too. I'm stuck on other project right now. I'll be back here as soon as I get chance, I did not forget about u. |
Does this problem exist in NS 7+ only? I am on
|
It's same thing starting from 6.5 and newer. It's mainly problem in new SDK and plugin haven't been updated to fulfill those updates / changes. Do you have problem with Android as well? @elconix I still did not have chance to try. I have two apps waiting to be updated. |
@markosole However, I will be starting with Android so I also will require a fix. Are there other options then this plugin? |
Hi all,
I have upgraded my tns to ns 7 and plugin isn't working any more properly for iOS 14.x . I am getting error:
TnsOneSignal.initWithLaunchOptionsAppId is not a function
My code is:
This was working fine and now it does not any more. Did anyone had same or similar problem?
The text was updated successfully, but these errors were encountered: