Why does my PFAnalytics not have trackAppOpeneWithLaunchOptions function? (IOS SWIFT)
Try
PFAnalytics.trackAppOpenedWithLaunchOptionsInBackground(launchOptions, block: nil)
instead of
PFAnalytics.trackAppOpenedWithLaunchOptions()
PFObject does not have a member named 'saveInBackground' in Xcode 6.0.1, Yosemite GM3
The saveInBackground
method is declared in the header to return a BFTask *
object, which is part of the Bolts framework. Make sure your project is linking the Bolts framework, and then add
#import <Bolts/Bolts.h>
to your bridging header.
This solved a few "missing" APIs in Swift for me (this one, as well as PFAnalytics.trackAppOpenedWithLaunchOptions
mentioned here: Why does my PFAnalytics not have trackAppOpeneWithLaunchOptions function? (IOS SWIFT)
Why does the browser tell me the parse is not defined even if I have imported it in the head of the HTML file?
Can you please test the code below?
<script src="https://cdnjs.cloudflare.com/ajax/libs/parse/2.1.0/parse.js"></script>
<script type="text/javascript">
function myFunction() {
Parse.initialize("APP_ID", "JS_KEY");
Parse.serverURL = 'https://parseapi.back4app.com/';
}
/</script>
How an I prevent the UIAlertView from appearing when a push notification is received while the app is in the foreground?
The didReceiveRemoteNotification
delegate method is called if
- The user is in the application when the notification is received, or
- The user engages a notification after receiving it outside the app.
You can choose how to handle the notification using application.applicationState
, which you have done. From How to respond to push notification view if app is already running in the background:
You can tell whether your app was just brought to the foreground or
not inapplication:didReceiveRemoteNotification:
using this bit of
code:- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if ( application.applicationState == UIApplicationStateActive )
// app was already in the foreground
else
// app was just brought from background to foreground
...
}
"Inactive" doesn't print because UIApplicationStateInactive
(UIApplicationState.Inactive
) is the case when the following is true:
The app is running in the foreground but is not receiving events. This might happen as a result of an interruption or because the app is transitioning to or from the background.
Source
So, what you're actually looking for is UIApplicationState.Background
:
if application.applicationState == UIApplicationState.Background {
PFAnalytics.trackAppOpenedWithRemoteNotificationPayloadInBackground(data, block:nil)
}
So, that solves the open from background issue, but what about when the user receives the notification in the app? You don't want the jarring popup, so the way to disable that is to get rid of its source, PFPush.handlePush()
.
All that handlePush:
does is create that alert view and present it to the user, so removing it will not affect anything else:
A default handler for push notifications while the app is active that could be used to mimic the behavior of iOS push notifications while the app is backgrounded or not running.
Source
That's it – just remove it and there will be no alert view.
If you want to increment the badge count, you still can:
if userInfo.objectForKey("badge") {
let badgeNumber: Int = userInfo.objectForKey("badge").integerValue
application.applicationIconBadgeNumber = badgeNumber
}
Related Topics
Arkit - How to Put 3D Object on Qrcode
How to Alloc/Dealloc Unsafe Pointers in Swift
How to Enable Swift Support for Existing Project in Flutter
How to Quit Swift Repl Without Using Ctrl-D
Storyboard Entry Point Missing
Present Actionsheet in Swiftui on iPad
How to Simulate Traits/Mixins in Swift
How to Avoid Using Anypublisher/Erasetoanypublisher All Over the Place
How to Recognize Continuous Touch in Swift
Nsuserdefaults in Swift - Implementing Type Safety
Get the Current Position of Scrollview in Swiftui
Swift - How to Save Audio from Avaudioengine, or from Audioplayernode? If Yes, How
Scenekit - Get Direction of Camera