I use the code below:
let request : GADRequest = GADRequest ()
request.testDevices = ["xxxxxxx",kGADSimulatorID]
But I am getting the below warning:
'testDevices' is deprecated: Use GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers.
Do I use a syntax to remove the warning?
You should use this:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = ["YOUR IDENTIFIER PRINTED ON DEBUGGER"]
Instead of:
request.testDevices = ["YOUR IDENTIFIER PRINTED ON DEBUGGER"]
Swift Solution
It turns out the AdMob/GoogleAdManager deviceId can be found by computing the MD5 of the advertisingIdentifier. This way you can retrieve and use the test deviceId in code without having to previously have got a device's identifier from the console log.
To avoid the faff of using an ObjC-Swift bridging header (getting MD5 via <CommonCrypto/CommonCrypto.h>), I'd suggest using a Swift wrapper around the CommonCrypto framework, e.g this one:
SwiftCrypto
Using the above framework (which adds an extension property to String for computing the MD5 hash), it is a simple matter of querying against:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers ?? []).contains(ASIdentifierManager.shared().advertisingIdentifier.uuidString.md5)
This is a modification to 10623169's answer.
To get a valid ID, for the current device, that can be set in "testDevices", get the MD5 of this: UIDevice.current.identifierForVendor?.uuidString
The asIdentifier value can be completely invalid if the user hasn't given permission for tracking. But the UIDevice.current.identifierForVendor is a valid UUID for the app, that will persist across launches (but perhaps not if you delete the app and reinstall).
Use the syntax to remove the warning:
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers
You don't have to set this at all. As the AdMob Developer Doc says:
iOS simulators are automatically configured as test devices.
Source: https://developers.google.com/admob/ios/test-ads#enable_test_devices
Related
I've just found a simple way to get the some CallLogs (CallerID, Username, To, From, Call duration, Date, Status, ...) from the new Linphone library for swift (SDK 5.0).
I just want to share it with you
Referring to Linphone's documentation, and some testings, I found at least 2 simple ways to retrieve the CallLog and read it:
1. Using CoreDelegateStub
CoreDelegateStub( onCallStateChanged: { (core: Core, call: Call, state: Call.State, message: String) in
So, you can use the call attribute to get the CallerID(Username) for example, like that:
call.callLog?.fromAddress?.username
Remember, the callLog object contains a ton of parameters that you can find in the documentation
2. Using Core from Linphone wrapper
var mCore: Core!
self.mCore.callLogs
In that way, you can retrieve all your call logs in an array, so you will need to choose an item and get the attributes from it like I've shown above.
self.mCore.callLogs[0].fromAddress?.username
My (non-sandboxed) app has an embedded XPC helper which runs as root.
I would like to reference the (real) user's home directory from inside my helper, but these usual suspects simply return /var/root:
FileManager.default.homeDirectoryForCurrentUser
NSHomeDirectory()
I can't simply pass Users/bob to my helper for security reasons — if an exploit managed to call my helper method with any URL it wished, and my helper did things based on that as root, I fear bad things could be achieved.
As vadian commented there are fundamental conceptual issues with what you're asking. What you probably actually want to do is be sure the process communicating with your helper tool is in fact trusted.
To do that you need to use SecCodeCreateWithXPCMessage and then use the resulting SecCode instance to validate the caller. For an example of how to do that, take a look at the acceptMessage function in the SecureXPC framework.
EDIT: Turns out there is a way to do this that does work from a Command Line Tool such as one installed with SMJobBless. This answer is adapted from Apple's Technical Q&A QA1133.
If you for whatever reason want to ignore the above, there's an approach you can take which may produce unexpected results if multiple users have active consoles. From Apple's documentation for SCDynamicStoreCopyConsoleUser: "Note that this function only provides information about the primary console. It does not provide any details about console sessions that have fast user switched out or about other consoles."
import SystemConfiguration
extension FileManager {
var homeDirectoryForConsoleUser: URL? {
var homeDirectory: URL?
if let consoleUser = SCDynamicStoreCopyConsoleUser(nil, nil, nil) as String?,
consoleUser != "loginwindow" {
homeDirectory = URL(fileURLWithPath: "/Users/\(consoleUser)")
}
return homeDirectory
}
}
And then you can make use of this anywhere in your helper tool:
if let homeDirectory = FileManager.default.homeDirectoryForConsoleUser {
// Do something useful here
}
I tried to change client page size in Azure server
it's default is 50 and I want to make it bigger
so i use Microsoft tutorial in this link
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-ios-how-to-use-client-library#querying
var client : MSClient?
let client = MSClient(applicationURLString: "AppUrl")
let table = client.tableWithName("TodoItem")
let query = table.query()
let pullSettings = MSPullSettings(pageSize: 3000)
but when I write
table.pullWithQuery(query, queryId:nil, settings: pullSettings) { (error) in
if let err = error {
print("ERROR ", err)
}
}
there are error "Value of type 'MSTable?' has no member 'pullWithQuery'"
what is the problem ?
is the function name changed ?
Two problems:
The documentation has not been updated for current versions of Swift
(an update request has been filed). The correct function name in modern Swift is pull rather than pullWithQuery.
The pullWithQuery function is on MSSyncTable, not MSTable. Pull is part of the offline sync system. The MSTable analog is read.
More details:
The SDK itself defines the function as MSSyncTable.pullWithQuery, but one of the features of Swift 3.0 is that it renames Objective C methods when it projects them into Swift to remove redundant arguments from the name, so verbWithX(X) becomes just verb(with:x) and pullWithQuery (MSQuery) becomes pull(with:MSQuery).
For more information on Swift 3 changes please see https://swift.org/blog/swift-3-0-released/ . I believe this particular change is SE-0005: Better Translation of Objective-C APIs Into Swift
If you download the Swift quickstart from your Azure Portal then you’ll get the correct modern pattern there:
self.table!.pull(with: self.table?.query(), queryId: "AllRecords")
or with your arguments:
self.table!.pull(with: self.table?.query(), queryId: nil, settings: pullSettings)
Does anyone know the method / commands to send, to enable and use multi-config support so I can store application specific data?
The SDK 2.0 Developer Guide mentions the AT*CONFIG_IDS command, but I'm not able to make it work. I'm trying the sample commands below:
// set the application ID
AT*CONFIG=12,"CUSTOM:application_id","2902050D"
// clear config ack
AT*CTRL=13,5,0
// set application description, using new app id
AT*CONFIG_IDS=14,"00000000","00000000","2902050D"
AT*CONFIG=15,"CUSTOM:application_desc","My SDK Test"
// clear config ack
AT*CTRL=16,5,0
// re-read config data
AT*CTRL=17,4,0
AT*CTRL=18,5,0
But in the returned config, nothing has changed:
custom:application_id = 00000000
custom:application_desc = Default application configuration
I've also tried prefixing the first CUSTOM:application_id config command with an CONFIG_IDS command but with no avail:
// set the application ID
AT*CONFIG_IDS=11,"00000000","00000000","00000000"
AT*CONFIG=12,"CUSTOM:application_id","2902050D"
Any ideas as to what I'm doing wrong?
After some trial and error, it seems that all configuration names should be all lower case; despite the category being upper cased in the Developer Guide examples.
Therefore the following works fine:
AT*CONFIG=12,"custom:application_id","2902050D"
AT*CTRL=13,5,0
AT*CONFIG_IDS=14,"00000000","00000000","2902050D"
AT*CONFIG=15,"custom:application_desc","My SDK Test"
AT*CTRL=16,5,0
AT*CTRL=17,4,0
AT*CTRL=18,5,0
I am using factory_girl and rspec2 for my testing. I have an issue with the following code:
let(:book) { build(:book, id: 1) }
book_path(book)
book_path statement is generating /books url instead of /books/1. I can use create, but any suggestions on how to fix this using build strategy?
I am using
rspec-rails (2.11.0)
factory_girl (3.5.0)
Try book.to_param (that's actually what book_path(book) is doing under the hood) and see what it returns. By default to_param returns id, but your book is not saved yet, so it can return nil.