I'm trying to display a banner ad on an iOS app using Yahoo's Flurry
class GameViewController: UIViewController, FlurryAdBannerDelegate{
// ...
override func viewDidAppear(_ animated: Bool){
// this ad space does exist
self.advertisement = FlurryAdBanner(space: "LevelBannerBottom")
self.advertisement!.adDelegate = self
self.advertisement!.fetchAndDisplayAd(in: self.view, viewControllerForPresentation: self)
}
// ...
}
When I do this, no advertisement is displayed, and Error in AdRequest: [Unknown Error] is printed to the console. There's no non-Flurry errors anywhere, or any crashes.
The ad space does exist (I'm pretty sure). I've also tried replacing setting the ad space to the number underneath Ad Unit ID (which I removed before uploading this image) -- FlurryAdBanner(space: "123456") -- ` but that gives the same result.
I've already waited 24 hours since I added the new ad unit, and I have added my device's IDFA under Test Device IDs on the dashboard.
I have debugging turned on, so a lot of stuff is printed to the console, but the most important stuff is this (I've removed all of the times and app name)
Successfully parsed ad request schema
Load AdUnit Timed out
Picked cached ad unit 0x0 with guid (null)
Successfully created ad request.
Sending AdRequest....
Sending AdRequest of size 1456....
Flurry: HTTP connection delegate received response[<NSHTTPURLResponse: 0x17402eba0> { URL: https://ads.flurry.com/v16/getAds.do } { status code: 200, headers {
Connection = "keep-alive";
"Content-Length" = 57;
"Content-Type" = "application/octet-stream";
Date = "Tue, 11 Oct 2016 02:52:52 GMT";
"FM-Checksum" = 734757664;
"Keep-Alive" = "timeout=10";
Server = nginx;
} }]
This is a ad response of len 57
Successfully parsed ad response schema
Error in AdRequest: [Unknown Error] # << this is the important error
FlurryAdCache: skipping adunit with empty or nil adspace
******* logAdEvent:
** [<FlurryAdEvent: 0x170249000> unfilled(4), T:10040]
** <FlurryAdLog: 0x170461a80> [S:1476154362553, RS:1476154362553 ID:1, GUID (null), {(
" ** [<FlurryAdEvent: 0x170249000> unfilled(4), T:10040] "
)} transmitted {{
}} ]**
********************
Although this shouldn't be causing the problem (I didn't have to provide any information about the app anywhere), the app isn't public on the iOS App Store yet.
What could be causing this error? Is it something to do with iOS 10? I'm using Flurry 7.6.6
I believe this is the result of a bug. Please try this work around:
Log in to https://dev.flurry.com
Click 'Classic Flurry' in the upper right corner
Click the applications tab
Select your app
Go to Manage -> App Info
See if you have a category assigned to your app
If not set a category and wait an hour or so
Retry the ad integration
Otherwise send us your api key and ad space name to support#flurry.com and we can look into it.
Related
I currently am unable to authorize the SquareReaserSDK with iOS (Swift).
I have a node instance that takes in an access_token.
I then call listLocations()
I provide the first location_id in the body of a CreateMobileAuthorizationCodeRequest()
I then pass the resulting mobile auth code to the client
After successfully retrieving a mobile auth token and providing that to the below, the first time this is called there is no callback. The block if statement never fires.
Redundant calls results in an authorization_already_in_progress error (the if statement is fired).
SQRDReaderSDK.shared.authorize(withCode: mobileAuthToken) { location, error in
if let authError = error {
print("Authorize SquareReaderSDK", authError.localizedDescription)
} else {
print("Authorize SquareReaderSDK", location)
Defaults[.establishment]?.squareMobileAuthToken = mobileAuthToken as! String
}
}
authorize() endpoint reference: https://developer.squareup.com/docs/api/reader/ios/Classes/SQRDReaderSDK.html#/Authorization
Redundant calls results in:
vvvvv SQUARE ERROR vvvvv
ERROR: Something went wrong. Please contact the developer of this application and provide them with this error code: authorization_already_in_progress
DEBUG CODE: authorization_already_in_progress
DEBUG MESSAGE: Authorization is already in progress. Please wait for SQRDReaderSDK.shared.authorize() to complete.
^^^^^ SQUARE ERROR ^^^^^
At any point while trying to authorize the device, I get the following error when trying to present the checkoutController:
Checkout Failed:
This device is not currently authorized to accept payments with Square.
After spending one day in google and stackOverflow testing every way to log in to instagram vía my own app, I'm almost sure I've tried everything but nothing worked.
I've downloaded instaAuth and tried it in my iOs 11 device. I get on screen error:
{"error_type": "OAuthForbiddenException", "code":403, "error_message", "You are not a sandbox user of this client"}
I'm testing with the only cliend ID that I have and the user is the admin.
In the log, I get a different error:
InstaAuth[3870:1257213] WF: === Starting WebFilter logging for process InstaAuth
2017-11-21 14:54:03.815613+0100 InstaAuth[3870:1257213] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2017-11-21 14:54:03.815717+0100 InstaAuth[3870:1257213] WF: _WebFilterIsActive returning: NO
I've tested the same code in the simulator (iphone 7+ iOs 10.2 and iphone 7+ iOs 11.1) and it worked (¿?!), the login screen appeared, I have been able to log-in and get the instagram token.
I've been looking at other posts that have the same error than my console log, but haven't found a solution for my problem. What I don't understand is how it can works in simulator and not in the device.
Any help would be appreciated
edit: with this code below I can open the url and even get the instagram token:
let instagramURL : URL = URL.init(string: "https://api.instagram.com/oauth/authorize/?client_id="+CInstagram.clientId+"&redirect_uri="+CInstagram.redirectUri+"&response_type=token")!
if (UIApplication.shared.canOpenURL(instagramURL))
{
if #available(iOS 10.0, *) {
UIApplication.shared.open(instagramURL)
} else {
// Fallback on earlier versions
}
}
The browser goes to instagram, and the url appears with the token, the only problem is I can't get this token back to my app because, when the user press the back button to go to my app, there is not any delegate method called with the final url and the token.
Vía webView, it throws me the same error (WF: _WebFilterIsActive returning: NO) but never ends in the final url with the token.
The only way I managed to get into the final url is opening it vía UIApplication.shared.open(instagramUrl)
but it seems there is no way to get a return value to my app because the instagram uri only let me put an url with http or https but not with a mobile format (exampleApp://) so my app is not called back.
We have an Azure Notification Hub set up, with APNS Configured in Production Mode, using our Production APNS Certificate.
We register our test devices (using TestFlight / Production build, and certificate) to APNS, and then to ANH with a tag dealer-1. We can send notifications using our production certificate and registered Device ID with success when using APNS directly, however, when we use 'Test Send' we get a 'Successful send' to 1 device (or however many we have registered). The notification is not received. If we then run 'Test Send' again, the are 0 devices to send to.
In the logs, we see 'APNS Errors' per device, per test send. I cannot see any way to view what the errors actually are though so this is an absolutely useless metric.
I have ran through all the troubleshooting steps and confirmed many times that everything is setup in 'Production'.
Having reviewed other questions, the answers have been along the lines of:
.. registering a sandbox certificate and then changing it to production. Unfortunately we created this hub from scratch as Production in an attempt to work around that potential issue.
.. registering sandbox devices (and thus tokens) against the production certificate. Unfortunately I have controlled this closely and ensured that we are only registering TestFlight builds (thus Production) against the ANH.
.. uploading the wrong certificate. I have confirmed with the Push Notification Tester, as above, that the certificate is correct (thumbprint confirmed, re-uploaded, etc) and works to send to the devices via Production APNS endpoint.
The resource name is: eight-technology/react-push-notification-hub
In-app registration process is as follows:
Device registers for push notifications
Registration event is handled in iOS Project (AppDelegate event)..
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
//base.RegisteredForRemoteNotifications(application, deviceToken);
App.ConfigurePushNotifications(deviceToken.ToString());
}
ConfigurePushNotifications is in the XF Shared Project..
public static void ConfigurePushNotifications(string deviceToken)
{
var azureComm = DependencyService.Get<Interop.IAzureCommunication>();
azureComm.RegisterForPushTags(
"sb://eight-technology.servicebus.windows.net/",
".. token ..",
"react-push-notification-hub",
deviceToken,
StateManager.SelectedNodes.Select(m => "dealer-" + m).ToArray());
}
The implementation is pretty much as per the sample code provided (contained in iOS project)
public class AzureCommunication : DealerwebReact.Interop.IAzureCommunication
{
public void RegisterForPushTags(string url, string key, string hubName, string deviceToken, string[] tags)
{
var cs = SBConnectionString.CreateListenAccess(new NSUrl(url), key);
var hub = new SBNotificationHub(cs, hubName);
hub.RegisterNativeAsync(deviceToken, new NSSet(tags), err =>
{
if (err != null)
Console.WriteLine("Error: " + err.Description);
else
Console.WriteLine("Success");
});
}
}
After a frustrating few days, and thanks to the help of Nikita G. and hvaughan3 I finally got to the root cause of my issue. As anticipated it wasn't any of the issues actually outlined, but was to do with the way we handled the cross-plat aspect of the registrations with Xamarin Forms.
That is, we stored our token in a class as a string. The NSData that is received as part of the iOS Device registration in RegisteredForRemoteNotifications has a ToString() method that is incompatible with sending to ANH. Furthermore, RegisterNativeAsync method from the Azure library requires an NSData which I assume Xamarin can morph a string into without warning or error, hence it was unknown that the two were somewhat incompatible.
Basically, to maintain cross platform functionality, we are now simply passing the token around as an object and performing the translation back to the original type in the platform-specific implementation of our push configuration method.
Our registration method now looks like this, note the explicit use of the NSData type so that it remains untouched whilst passing through the Xamarin Forms layer:
public void RegisterForPushTags(string url, string key, string hubName, object deviceToken, string[] tags)
{
var cs = SBConnectionString.CreateListenAccess(new NSUrl(url), key);
var hub = new SBNotificationHub(cs, hubName);
hub.RegisterNativeAsync((NSData)deviceToken, new NSSet(tags), err =>
{
if (err != null)
Console.WriteLine("Error: " + err.Description);
else
Console.WriteLine("Success");
});
}
Is this the guide you used for troubleshooting?
Is there a chance you somehow do any string (or any other type of) processing on the APN handle before you register your device? The 'APNS errors' you're seeing seem to be 'invalid token size'. Since I don't know what's going on in your code, it's hard to suggest what exactly might it be, but maybe would help you.
A similar thing happened to me when the device would register correctly but as soon as a notification was sent, the devices would disappear from the list. It always turned out to be an issue with the APNS certificate that was configured within the Notification Hub was not connected properly to the App ID and/or the app was not being signed with the correct provisioning profile.
I'm using the new push-notification service on bluemix, with an iOS device.
The device registers successfully. When I check with the REST-API, I see the device-ID, token and so on.
However, running the iOS-app on the device crashes the app on first run and registration.
The crash happens in CDVMFPPush.swift in func didRegisterForRemoteNotifications(deviceToken: NSData)
on line 309 (let pushToken = response.responseJson["token"] as! String).
I did a print(response) in this function and it seems that responseJson only contains the deviceId and the userId. The token is missing.
When I use the REST-Api again to do the same request, the response seems to be complete.
I think that because of this error the push registration doesn't finish, as I don't receive any notifications when I try to run the service in sandbox-mode.
Any ideas?
(P.S. I checked this solution - iOS Application crashes when trying to register the device to IBM Mobile First Push service on Bluemix - the linker flag is set [-ObjC])
Here's the request from my console (app-id/secret/device is edited)
Response text: {"createdTime":"2016-06-07T15:28:55Z","lastUpdatedTime":"2016-06-07T15:28:55Z","createdMode":"API","deviceId":"xxxx","userId":"","token":"xxxx","platform":"A","href":"https://myapp.mybluemix.net:443/imfpush/v1/apps/xxxx/devices/xxxx"}
httpStatus: 201
responseHeaders: {
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Tue, 07 Jun 2016 15:28:55 GMT";
Location = "https://myapp.mybluemix.net:443/imfpush/v1/apps/xxxx/devices/xxxx";
"Transfer-Encoding" = Identity;
"X-Backside-Transport" = "OK OK";
"X-Global-Transaction-ID" = xxxx;
"X-Powered-By" = "Servlet/3.0";
}
responseJson: {
deviceId = "xxxxx";
userId = "";
}
We've updated the MFPPush iOS Framework to resolve the issue and the MFPPush Cordova Plugin has been updated to incorporate these fixes. We suspect the crashes were caused by the fact that you were being sent a second IMFResponse object through the callback and this second IMFResponse's responseJson didn't have the token as you saw which was resulting in the crash. These changes should resolve that issue.
Easiest way to update the plugin is just to remove the old and re-add it, you should be on version 1.0.14 of ibm-mfp-push to see the fixes.
Can see the update on the related Github as of this morning as well
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-cordova-plugin-push
I feel I am the first one in the universe trying to get iOS swift working with Azure, not much help out there.
I followed this Create an iOS app
and then Add Push Notifications to your iOS App. I am supposed to be able to do a successful push notification from iPhone, but I get this error. btw: I can get my C# code to trigger in visual studio in my pc (using this tutorial), so the request seems to be working, but the response sucks. Any one knows how to fix it!!
Error registering for notifications: Optional("Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1302 \"{\"message\":\"An error has occurred.\"}\" UserInfo={com.Microsoft.MicrosoftAzureMobile.ErrorRequestKey=<NSMutableURLRequest: 0x14cebf780> { URL: http://<mysite>.azurewebsites.net/push/installations/1E32E9B5-E976-4CCD-BD61-D026D3F4FF1C }, com.Microsoft.MicrosoftAzureMobile.ErrorResponseKey=<NSHTTPURLResponse: 0x14cec54b0> { URL: http://<mysite>.azurewebsites.net/push/installations/1E32E9B5-E976-4CCD-BD61-D026D3F4FF1C } { status code: 500, headers {\n \"Content-Length\" = 36;\n \"Content-Type\" = \"application/json; charset=utf-8\";\n Date = \"Wed, 11 May 2016 21:39:39 GMT\";\n Server = \"Microsoft-IIS/8.0\";\n \"Set-Cookie\" = \"ARRAffinity=8d79cd782ff16b44f7f280b76e2bc5564d86e0d1b228227b8e0033f4bb1c4582;Path=/;Domain=<mysite>.azurewebsites.net\";\n \"X-Powered-By\" = \"ASP.NET\";\n} }, NSLocalizedDescription={\"message\":\"An error has occurred.\"}}")
UPDATE #1
The only url I have is the one per the tutorial. The rest of the code is identical to the ones I mentioned in the links (I copied it character by character):
class ClientManager {
static let sharedClient = MSClient(applicationURLString: "http://<mysite>.azurewebsites.net")
}
UPDATE #2
#Pau Senabre I am working with swift not Objective-C per my question (see my tags under question), so I don't have an .m file per your step #1. I also don't have the logErrorIfNotNil you mentioned. My method (which is generated by Azure before modifications) looks like this:
#IBAction func addItem(sender : AnyObject) {
self.performSegueWithIdentifier("addItem", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!)
{
if segue.identifier == "addItem" {
let todoController = segue.destinationViewController as! ToDoItemViewController
todoController.delegate = self
}
}
UPDATE #3
#Pau Senabre My goal is to do mobile apps/services, not mobile engagement. See the difference here. btw: I had followed the azure engagement example when I started playing with it and had worked for me. But my need now is web/mobile apps. So, does what you suggested still apply for my need?
Could you please post some code? I think you may be using a wrong URL in a certain place.
To UPDATE #2
Check the following link:
https://github.com/Azure/azure-content/blob/master/articles/mobile-engagement/mobile-engagement-ios-swift-get-started.md
In section Modify your Application Delegate make sure you create a reach module and your existing Engagement initialization has all the init Values.
EngagementAgent.init("Endpoint={YOUR_APP_COLLECTION.DOMAIN};SdkKey={YOUR_SDK_KEY};AppId={YOUR_APPID}", modulesArray:[reach])
The error Code provided Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1302 matches to a bad request. If you are entering some data, make beforehand a Data Input Validation:
1 In the TodoService.m file, locate the addItem method search for the [self logErrorIfNotNil:error]; line of code. Beneath that line of code, replace the remainder of the completion block with the following code that checks to see if there was an error in the request and if that error code was –1302, indicating a bad request:
BOOL badRequest = ((error) && (error.code == -1302));
// detect text validation error from service.
if (!badRequest) // The service responded appropriately
{
NSUInteger index = [itemscount];
[(NSMutableArray *)itemsinsertObject:result atIndex:index];
// Let the caller know that we finished
completion(index);
}
2 Build and run; you can see in the Xcode output window that the bad request error from the service was handled:
2012-10-23 22:01:32.169 Quickstart[5932:11303] ERROR Error Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain Code=-1302 “Text length must be under 10″ UserInfo=0x7193850 {NSLocalizedDescription=Text length must be under 10, com.Microsoft.WindowsAzureMobileServices.ErrorResponseKey=, com.Microsoft.WindowsAzureMobileServices.ErrorRequestKey=https://task.azure-mobile.net/tables/TodoItem>}
3 Finally, in the TodoService.m file, locate the logErrorIfNotNil method, which handles the logging of errors to the output window. Inside the if code block, just below the line NSLog(#”ERROR %#”, error); add the following if block:
// added to display description of bad request
if (error.code == -1302){
UIAlertView *av =
[[UIAlertView alloc]
initWithTitle:#”Request Failed”
message:error.localizedDescription
delegate:nil
cancelButtonTitle:#”OK”
otherButtonTitles:nil
];
[av show];
}
Aditionally, review the following steps in the Azure Setup, maybe you are missing something at some point:
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-ios-get-started-push/
1 Create a Notification Hub
This creates a new notification hub and connects it to your mobile app. If you have an existing notification hub, you can choose to connect it to your Mobile App backend instead of creating a new one.
2 Register app for push notifications
Register an App ID for your app. Create an explicit App ID (not a wildcard App ID) and for Bundle ID, use the exact Bundle ID that is in your Xcode quickstart project. It is also crucial that you check the Push Notifications option.
Next, configuring push notifications. You may create either a "Development" or "Distribution" SSL certificate (remember to select the corresponding option in the Azure portal later.)
3 Configure Azure to send push notifications
In the Azure portal, click Browse All > App Services > your Mobile App backend > Settings > Mobile > Push > Apple Push Notification Services > Upload Certificate. Upload the .p12 file, selecting the correct Mode (corresponding to whether the client SSL certificate you generated earlier was Development or Distribution.)
4 Update server project to send push notifications
Replace the PostTodoItem method with the following code:
public async Task<IHttpActionResult> PostTodoItem(TodoItem item)
{
TodoItem current = await InsertAsync(item);
// Get the settings for the server project.
HttpConfiguration config = this.Configuration;
MobileAppSettingsDictionary settings =
this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings();
// Get the Notification Hubs credentials for the Mobile App.
string notificationHubName = settings.NotificationHubName;
string notificationHubConnection = settings
.Connections[MobileAppSettingsKeys.NotificationHubConnectionString].ConnectionString;
// Create a new Notification Hub client.
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString(notificationHubConnection, notificationHubName);
// iOS payload
var appleNotificationPayload = "{\"aps\":{\"alert\":\"" + item.Text + "\"}}";
try
{
// Send the push notification and log the results.
var result = await hub.SendAppleNativeNotificationAsync(appleNotificationPayload);
// Write the success result to the logs.
config.Services.GetTraceWriter().Info(result.State.ToString());
}
catch (System.Exception ex)
{
// Write the failure result to the logs.
config.Services.GetTraceWriter()
.Error(ex.Message, null, "Push.SendAsync Error");
}
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
this is the proper answer from another question I had earlier, which fixes both: Registration and Receiving push notifications. I said this in here:
I finally have been able to receive notifications last night. I went ahead and redid an entire walk-through of all apple-side installation steps using this tutorial: Sending push notifications to iOS with Azure Notification Hubs then the azure-side of things using this: Create an iOS app and Add Push Notifications to your iOS App. That took care of the registering the app of the device successfully, which I was able to verify using the note of AdrianHall in this thread. But that wasn't enough. The Azure tutorials fell short detailing the steps needed in Xcode, which I found here: [How To] Setup Remote Push Notification in iOS - Swift 2.0 Code I didn't have to setup any "push notification" in Xcode or anything like that.
I hope this detailed answer will save you many hours of digging through.