Apple Push Notifications from WebApi app - ios

I am using PushSharp for Apple Push Notifications and it is working from console app and windows service on Windows 8 and Windows Server 2008R2, but the same code transferred to WebApi app on the same computers does not work. I've installed certificate and private key via mmc in Personal (the private key is available, granted permission for IIS_USRS) and Trusted Root Certificate Authorities.
Code is kind of obvious, but just in case:
var push = PushBroker();
var appleCert = File.ReadAllBytes("C:\Users\Documents\Certificates\Push.p12");
push.RegisterAppleService(new PushSharp.Apple.ApplePushChannelSettings(false, appleCert, "pwd"));
PushSharp.Apple.AppleNotification notif = new PushSharp.Apple.AppleNotification()
.ForDeviceToken("xxx")
.WithAlert("Updated...")
.WithBadge(1)
.WithSound("default");
push.QueueNotification(notif);
//Wait for queue to finish
push.StopAllServices(true);
No errors/exceptions etc., its just the iPhone device does not get notifications when initiated in WebApi app.

Have you checked all the event handles for errors? There's alot of them on the PushBroker instance where you can subscribe to intercept the error (if there is any).
Subscribe for: OnServiceException and OnNotificationFailed.
Check if the IIS|app|users|roles has all the privileges to access the web.

When I had this error it was a certificate issue. Make sure you are using the correct certificate for production, since the first parameter is false in ApplePushChannelSettings, otherwise the message will not get delivered. Also step through the code and see if any errors are being generated but not logged.

Related

Self-hosted Signal iOS is unable to connect to internet

same issue, other person: https://github.com/signalapp/Signal-iOS/issues/2282
We've checked out the Signal-iOS repository and we're trying to make it connect to another server. We're running an instance of the server at signal.appcraft.nl. We've modified the defines in SignalServiceKit/src/TSConstants.h to match our server and we've changed the domains in App Transport Security Settings in /Signal/Signal-Info.plist
We also cloned the Android app and that one we managed to got working just fine. The iOS app seems not to be able to connect to the internet at all without a clear error. The first HTTP call that is done is GET https://signal.appcraft.nl/v1/accounts/sms/code/<MYNUMBER>?client=ios. When we invoke that URL using curl, we get a response (and SMS) just fine. From the app, we receive a Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data. error. We also changed NSAllowsArbitraryLoads to Yes.
We've added a breakpoint in /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
# /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
(lldb) expr error
(NSURLError *) $3 = 0x00000001c0244800 domain: #"NSURLErrorDomain" - code: 18446744073709550617
Please advise

Unable to Test BlackBerry PushService SDK on Simulator

I am Java Developer but recently I got some project related to BlackBerry Push Service implementation. My objective is to write the server side implementation for the Push Initiator i.e. the content provider. but to test this I need to use some sample push enabled app also.
I have gone through the BB Developers guide and have done below steps:
Registered for BB Push service evaluation API and received the confirmation mail with all the required details like: appId, pwd, PPG Url for BIS, port number etc.
installed the BB Push installer for low-level-Push-Imitator(i.e. the web app content provider) and the sample push enabled app(PushDemo_sample available on BB Push service Developers guide).
Now I am testing this push-enabled app on simulator and trying to register. But as the sample app tries to first subscribe with the Push-Initiator(CP) before registering with BB Push server. I have commented the below code as I don't want the subscription part.
The RegisterCommand class handles the subscription and registration.
protected void execute() throws Exception {
// first we register with Content Provider
Logger.log("Reached RegidterCommand execute() method .. but eacapingCMD_SUBSCRIBE");
//ContentProviderProtocol.performCommand( ContentProviderProtocol.CMD_SUBSCRIBE, username, password, isEnterprise, tx ); // commented
// if the registration is successful we register with BPS
Logger.log("Now Going to register with PPG");
BpasProtocol bpasProtocol = PushLibFactory.getBpasProtocol();
bpasProtocol.register( tx, isEnterprise );
// update the registered state
PersistentStorage.setRegistered( true );
}
But after configuring the app with the proper appId, PortNumber and BPS server URL, dummy push initiator application url, When I clicked on register, It is showing some IOException:
Command 'register' failed with error: java.io.IOException: could not find a service book entry for IPPP.
In the app logs on simulator I can see that it is trying to open the BB Push eval url with some parameters appended after the url like below:
Opening URL: http://cpXXXX.pushapi.eval.blackberry.com/mss/PD_subReg?serviceid=XXXX-sxxxxxxxxxxxxxxxxxxxxxxxxxxxx&osversion=7.1.0.318&model=9900&deviceside=false&ConectionType=mds-public
Here I am just trying to register my simulator with the BB Push server. Is it not possible to test the Push service on simulator? or I am doing anything wrong?
and one more doubt how the register() method of PushLib50 class of the sample push app is appending the extra parameters after the eval URL?
Please help. Point out if I am doing anything wrong to implement the push service.
You cant test push notification in simulator. you need real device for that.
Refer this site
The BlackBerry Push Service is an essential component of the real-time, always-on experience of BlackBerry smartphones. It offers an efficient and reliable way of sending information to your users. It also lets your application process information in the background and notify users when their attention is required.

Blackberry Push Notification-Push service sdk error

I install the blackberry sdk push server and i get app id and the port and i used the tutorial SamplePushEnabledApp i registred it with those data
Application ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPG Base URL** http://pushapi.eval.blackberry.com
Push Port: xxxxxxxx
For push initiator application i use the url https://XX.XX.XX.XX:8443/sample-push-initiator/ successfully create application using this, provide APPID, name and service level = Push-Essential. appID is same as provide by RIM.
I am trying to push msg from push menu item but it's give me error INVALID subscribers.
I had add subscribers name as APP_ID given by RIM, I had also tried device PIN No. as subscriber name but same error occurs.
plz help me to solve this issue.
Is there any solution for that?
There are three things required to sent a request from client side: APP id, push port and PPG base url
and three things required to send a response from server side :PPG base url, push username and push password
check whether you are using the exact credentials that are provided by Blackberry. If these dont match, it gives the above error
Though this may be very late to answer your problem/issue faced while implementing push service in BB device, But as, very recently I successfully able to implement this and I know how difficult to do this if you are not a BB app developer.
Hope you have gone through the below url for installing BB push service sdk on your PC.
http://developer.blackberry.com/bbos/java/documentation/push_service_sdk.html
http://developer.blackberry.com/bbos/java/documentation/developing_push_enabled_app.html
So for this if you are able to install the push service sdk(bpss-1.2.0.29.exe) you will be having one BPSS directory and under this the below thing will get created.
apache-tomcat-7.0.26
logs
pushsdk-high-level
pushsdk-low-level
Uninstall_BPSS
Push_Service_SDK_for_Java_InstallLog.log
Now I have used the pushsdk-low-level to push.
you can access this web app(push initiator cum content provider) by
https://localhost:8443/pushsdk-low-level
But before start pushing from this low-level push initiator you need to properly install the sample pushDemo app on your device.
NOTE: You can't test push service using the simulator.
Then you need to register with the Port(XXXXX), AppId(XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXX) and BPS server URL: http://cpXXXX.pushapi.eval.blackberry.com, Push Initiator Application URL: http://XX.XXXX.XXX.XX:8443/pushsdk-low-level, and use pubic(BIS) network selected.
Now let me tell you what this sample pushDemo does.
first it will try to use the Push initiator application URL to subcribe/store the BB device PIN to have the information about all PINs that have been register with your Push initiator(here our push-low-level app). But for testing this you can ignore by commenting the below code line in RegisterCommand.java class of the sample PushDemo app
ContentProviderProtocol.performCommand( ContentProviderProtocol.CMD_SUBSCRIBE, username, password, isEnterprise, tx );
Now run this modified app on you device and insert all data required for registration, you will be asked to input username/password, give anything. and register it should register successfully.
Once you have successfully registered your app on your BB device.
Now you should be able to push from your push-low-level web app to your pushDemo client app on your device. NOTE: the address that is been asked on push-low-level push page is nothing but the PIN of your device.
Ping me if you any other help on implementing this.

How does an iOS device identify itself to server without user log in

I am writing an iOS app with a Rails API backend. The Rails backend will serve JSON data to the app. I have the following requirements.
The app will be a free download
The app will show data on a map
The app will show data in the vicinity of the user
Upon loading the app the device should send some unique identifier to the server identifying itself as a device that is running this app.
There will be no authentication for the user as it is not required. The data is available to anyone who downloads the app. All the server needs to know is that the client is a device running the app. The server cannot serve data to any other client
I would like to run the data using SSL between the device and server
The user location will be sent to the server and the server returns the corresponding pieces of data that are in the vicinity of the user
The client receives the JSON and caches the data locally.
Question: Given these requirements, how to set up steps 4 & 5?
Also: If I want to search more on this topic what keywords should I be googling for?
Consider using OpenUDID or SecureUDID.
I give you 2 options.
First of all, the easy way. From some time, apple forbids access to the device ID. However, they give you a device token instead.
To get this unique token, the user must register for remote notification.
Upon application launching, call the following function:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
Then this callback will be called:
- (void)application:didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken.
Send the token to your server and you're done. Problems with this approach are obvious. Your user will have to register for remote notification.
Another approach is to use the MAC address of the wi-fi board.
To do this:
IPAddress.h
IPAddress.c
Import this files into your project.
Then use this function:
InitAddresses();
GetHWAddresses();
for (int i=0; i<MAXADDRS; ++i)
{
//There is a way you can obtain more info about the hw_addrs, but in general, it's the first.
NSLog(#"MAC: %s", hw_addrs[i]);
}
FreeAddresses();
Create a hash using the mac address above and you're done.
Hope it helps.
Upon first launch, the app sends a request to the server saying Hi, I'm a new client, give me an id! The server generates a new, random id and sends it back. The app saves the id locally and uses it henceforth to uniquely identify itself.

BlackBerry Push Service return rc=10002, what that means?

when i try to register to the Blackberry push service from the real device i receive this response from their server "rc=10002"and wont register to the service.
what this response means and why im getting this now (the same code was working fine at the same device and network).
Thanks.
From the source code included in the API examples rc == 10002:
The push application id specified is
null or empty or if the push
application with the given id cannot
be found.

Resources