PushNotification OneSignal Issue - ios

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

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!

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.

Linker Command Failed Facebook Sdk

I am new to iOS and trying to implement Facebook SDK in a project using AppGuru Facebook integration in Swift tutorial. But I am facing this linker command error while building my app:
error is framework not found Bolts for architecture x84_64(linker command failed with exit code 1)
Here is a screenshot:
Download demo project with facebook login from below URL. you have to configure your facebook app id.
Download
You have to import this 3 frameworks in your project.
Check on this
https://developers.facebook.com/docs/ios
https://developers.facebook.com/docs/facebook-login/ios
Framework search path - add below line
$(PROJECT_DIR)/Projectname/FacebookSDK
Also check, bolts, core and login kit of facebook has to be in build phase -> Link binary with libraries
Follow steps -
Go to your project setting page
Select your project (left side)
Click the Build Settings tab
Search Bitcode
Set Enable Bitcode to No
I had the same error. I deleted the ParseFacebookUtils.framework library from my project and kept only the ParseFacebookUtilsV4.framework.
When using the AWS Mobile SDK for iOS and Facebook SDK together, you should not import Bolts.framework in your project. If you remove it, it should compile.
Copy the frameworks into the project but, unlike what Facebook tutorial suggests, select "Copy items into destination group's folder". I did that and it worked fine for me.

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

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'

Unable to use Google Analytics for iOS

I don't know what Happens to the code or google.
I just Downloaded the Sample App for Google Analytics for Google.
I downloaded it via pod using:
pod try Google
and chooses the option for Analytics.
After downloading when I build the project I am getting Linker Error.
Fully Stuck Tried All The way available in SO.
Removed -ObjC Flag
Removed -force-load Flag
Changed Load Common Section from Yes to NO
But none of the way help me Out. What is the issue with it.
Here is the Screen shot of the Error:
Here is the Following reason of this ERROR :
*Note - Integrated GooGle Analytic without CocoaPods.
If latest GA(Google Analytics) sdk is using then better to upgrade to Xcode 7 otherwise it will give you duplicate error (even if configured properly)
Running with Xcode 6.2 or < Xcode 7 then better to download September (August) Release Sdk.
Go with Xcode and select GA folder and right click - choose show in Finder then all files should be there . If yes then check is there two different copy exists in other folder .
Thanks
It basically says that there are functions duplications in the project...
Make sure the following:
The project does not have #import for .m files by mistake
In the projects build phases there are no file names duplications
There are no initialized variables in .h files e.g "int
variableA = 5"
If none of the above works, remove in project settings Other Linker
Flags "-ObjC", that will allow to load the same functions more then
one time.

Resources