Push notification with OneSignal: What means "No Push Token"? - ios

I'm using OneSignal for push notifications.
In the subscribed list some devices/users are marked with No (No Push Token). Explanation says: This user has no push token and cannot be targeted.
That occurs for iOS devices as well as for Android devices.
What does it mean? Why does it happen? How to change it?

This means OneSignal did not get a pushToken from the device however the device was able to register with your OneSignal account. On iOS the pushToken is known as the device token, on Android this is the Google registration id.
Depending on the OneSignal SDK you're using there is a setLogLevel function that can be called before you call OneSignal init to add additional logging. This will be printed in the Xcode log for iOS or adb logcat for Android. Also make sure you are using the last OneSignal SDK.
You can also contact OneSignal through the help bubble on the bottom of the page while logged in and they can check your account to help diagnose the issue.

Could you check if the "Push Notifications" capability is turned on? If it is not, turn it on and see if it works, otherwise keep reading.
Make sure you're running the latest version of the OneSignal SDK (2.1.14)
as this version should have resolved the issue. Next, try the following fixes:
Fix 1
From the navigation panel, select your top blue project. Then select your target and navigate to the Build Settings. Search for other linker flags and add the following entry: -ObjC
Do a project clean and run again, see if it works.
Fix 2
In your bridging header (if you have one), or on any header file that is visible to your App Delegate, create an extension for OneSignal class in which you define the following interface method:
+ (void)didRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken;
Next, override the didRegisterForRemoteNotifications delegate method in your app delegate and call the above method on OneSignal and pass both parameters to the SDK.

Note that there was a pretty significant flaw in the OneSignal SDK when used in XCode 8 up to version 2.1.10 that resulted in these No push token registrations for iOS devices when including the package using Cocoapods (the recommended approach). Make sure you update your pod.
See the release notes for 2.1.11:
Fixed a 'No Push Token' issue in 2.1.10 that would happen when OneSignal was downloaded through CocoaPods and included other pods that used the -ObjC flag.

Make sure that your Xcode project has "Push Notifications" and "Remote notifications" enabled.

As other answer mentioned, there is a bug in 2.1.10 for CocoaPods setup. So I changed
from
pod 'OneSignal' ## points to 2.1.10
to
pod 'OneSignal', :git => 'https://github.com/OneSignal/OneSignal-iOS-SDK.git', :branch => 'master'

Related

Can't get debug token for Firebase App Check for my Flutter iOS App

So I recently started setting up app check for my existing Flutter project (for both android and iOS platforms). I've had no problem with android's "Play Integrity", got the necessary debug token, and can successfully send and retrieve data to/from firestore (app check for firestore is currently enforced for my project).
The problem is, I can not get such a debug key for my iOS app. I will list the sources I've used and what I've tried so far.
I have firebase_app_check: ^0.1.1+8 installed via pubspec.yaml
I also added pod 'FirebaseAppCheck' to my Podfile
I have the necessary initialization code in my main.dart: await FirebaseAppCheck.instance.activate(...);
For "DeviceCheck", I am using THE SAME private key that I am using
for "Sign in With Apple" (which I have implemented successfully). I
have also enabled the checkbox for DeviceCheck in the settings of
that private key (in Apple Developer).
For my App ID (Apple Developer > Identifiers > App IDs), I have also
enabled the checkbox for "App Attest".
I have put "-FIRDebugEnabled" as an argument passed on launch in
XCode > Product > Scheme > Edit Scheme.
I always uninstall my app from my iOS simulator (iOS 16.2) or real device (iOS 16.1.2),
before trying again, because I have read across multiple forums that
the debug token only gets printed to the output the first time you
run your app.
I have also added these 4 lines of code in my AppDelegate.swift from here:
#if DEBUG
let providerFactory = AppCheckDebugProviderFactory()
AppCheck.setAppCheckProviderFactory(providerFactory)
#endif
Official firebase docs "iOS+ (App Attest)":
I have NOT copied ANY code from this page of the official docs, as I assume it's for native iOS apps only, and not for flutter, and I don't know where exactly I would have to put that code. I have only added the pod dependency and run pod install.
I don't have a .entitlements file.
So after all those steps, I'm apparently supposed to expect to find a debug token in my run output, as in:
Yet the only relevant output I can find is the following:
Runner[72719:33546579] 10.3.0 - [FirebaseFirestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. (com.apple.devicecheck.error error 1.)'
If it matters:
I have NOT YET uploaded my iOS app to apple developer, app store connect or whatever (I'm not yet familiar with the process of publishing to the app store).
Neither have I uploaded my android app to Google Play console or created an app there (for this project).
Don't tell me anything about firestore rules. I already had that set up long ago, and everything worked just fine before I started integrating App Check.
Don't recommend any 3rd party plugins to me, I will only use official ones.
The firebase documentation says:
Tip: Confirm in your Xcode project's build settings that it passes the DEBUG flag to the Swift compiler
Try removing the '#if DEBUG' and '#endif' and run the app.
If it works, it mean you have missed that step
I was not able to find that build setting, so i just removed those lines from the AppDelegate, but i need to keep in mind to remove the other 2 lines while building the release mode
See this answer on the flutterfire Github issues page. Basically, call setAppCheckProviderFactory before GeneratedPluginRegistrant.register(with: self) in the app delegate file. I was investigating the same issue and it fixed it for me (the debug token was instantly printed out in Xcode's debug output). Hope it helps you as well!

How to add push notifications to iOS app (cordova-plugin-firebasex)?

I am trying to add push notifications to iOS app but the notifications never arrive.
Things I've done so far are:
Add .p8 key to firebase project.
Add push notification to bundle ID.
Add remote notifications to app capabilities.
The push notifications work fine on the android app. iOS and android use a common backend for sending notifications.
I can generate a token by calling getToken and I can also get the APNS token.
I can also see an error in the console [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][__a_hex_address__] get output frames failed, state 8196. Not sure if it is relevant.
Also when I open the project in XCode I don't see any entitlements file in 'Resources' directory
I am using Cordova version 10 and Cordova ios version 6.2.0.
You have to open the WORKSPACE in Xcode and not the project. Also you have to make sure that cocoa pods have been setup and update as per the dev's doc.

OneSignal integration in iOS 8.0 Swift

I tried to integrate onesignal push library with my iOS app by followng their tutorial(https://documentation.onesignal.com/docs/ios-sdk-setup). However after adding OneSignal pod using cocoapods I'm getting following error
/Pods/IQKeyboardManagerSwift/IQKeyboardManagerSwift/IQKeyboardManager.swift:514:35:
'shared' is unavailable: Use view controller based solutions where
appropriate instead.
IQKeyboardManagerSwift is another pod added using cocoapods.
I tried various solutions mentioned in Stackoverflow but nothing worked. Is there anyway to fix this issue permanently?
Skip the 1st step (1. Add Notification Service Extension) in the tutorial. Then it will run without any issue.

OneSignal iOS issue "No Push Token" with SDK 2.0.7

I am confronting a weird error from OneSignal and push notifications. I have 3 devices (2 iPhones, 1 mini iPad). After i completed the entire process of Push notifications, only my iPad receives push notifications from OneSignal. All my devices are registered in my Developer Account and what i found is the most weird situation is that i NSLOG the didRegisterForRemoteNotificationsWithDeviceToken to see if each device connected receives a token and they all indeed get a token but for some reason OneSignal doesn't. Only the iPad token. The only difference that i could see is that the iPad is 9.3.2 and both iPhones are 9.3.4. The same app is installed on all devices, the oneSignal registration method is called from AppDelegate. Does anyone have been struggling with this issue as well? I attached an image of my oneSignal account. Thanks in advance.
OneSignal All Users dashboard
Well finally after a week deleting and creating certificates more than 100 times, provisioning profiles, etc i found the problem.
I am using objective-c so it is necessary to use the -ObjC flag.
Go to project > Your Target > Build Settings > on the search bar write other linker flags, the section will come up and by double click on it, it will allow you to add -ObjC
Without this flag, the SDK wouldn't register the DeviceToken.
Also if you are using Parse SDK, or GoogleMaps SDK, or Facebook SDK, you probably will have a conflict. The posible solutions are:
Parse SDK (I don't know if using parse server the conflict appears) : Delete ParseCrashReporting ParseFacebookUtils ParseTwitterUtils
Facebook SDK (Maybe with new versions, this won't be necessary): delete theFBAudienceNetwork
GoogleMaps: Basically the GoogleMaps SDK doesn't work with the -ObjC flag, so i using now the WEB API using HTTP Calls with JSON Responses. (It is all explained on the GoogleMaps Developers website)
Hope this will help someone that is struggling badly like i was.
Please any question about this subject don't hesitate to ask me about it. I think that right now i know every possible fail.
You're my hero. I've been struggling with this for a month. I have even talked with OneSignal about it several times and they had no clue why this was happening to me! Thanks again!
This issue has been fixed as of the 2.1.11 version of the SDK. Make sure to run a pod update if you're managing the SDK with CocoaPods.

PushNotification OneSignal Issue

im using OneSignal SDK for PushNotification in my iOS App
when i done everything in the Project and run on real device, OneSignal Says :
"This user has no push token and cannot be targeted."
i checked every thing, ex : codes, profiles.
I was struggling with the same problem.
Are you using objective-c? If so, you need to add the -ObjC flag to your project. Without it, the OneSignal SDK won't work.
On XCode, go to your target project > Build Settings > find Other Linker Flags and add -ObjC Flag.
Sometimes this could generate some conflicts with other SDKs (Such as Parse, GoogleMaps, Facebook..)
Take a look to my answer here for any possibly scenario about this:
https://stackoverflow.com/a/39135807/2551707

Resources