I'm implementing the ClassyTaxiAppKotlin + ClassyTaxiServer project but without success.
I followed all the steps in the tutorial.
Apparently the ClassyTaxiAppKotlin android app is functional, processes the subscription purchase order and sends the information to the CLOUD FUNCTIONS, but does not receive the purchase registration/confirmation.
In my understanding, upon receiving the payment confirmation, PLAY STORE must send this confirmation to the ClassyTaxiServer server so that the server returns the registration/confirmation of the purchase and grants access to the ClassyTaxiAppKotlin application.
So when confirming payment in ClassyTaxiAppKotlin app, I notice that I get some logs in firebase functions from (instanceId_register_v2, realtime_notification_listener AND subscription_register_v2), but the registration/confirmation of payment doesn't complete due to a server error (500) and doesn't release the access in the ClassyTaxiAppKotlin app.
Note: service-account.json is already configured
Does anyone have any idea why this error is occurring and indicate how I can solve it?
Code where the error points:
private async querySubscriptionPurchaseWithTriggerV2(packageName: string, product: string, purchaseToken: string, triggerNotificationType?: NotificationType): Promise<SubscriptionPurchaseV2> {
// STEP 1. Query Play Developer API to verify the purchase token
const apiResponseV2 = await new Promise((resolve, reject) => {
this.playDeveloperApiClient.purchases.subscriptionsv2.get({ // <<=== Server error: Cannot read property 'get' of undefined
packageName: packageName,
token: purchaseToken
}, (err, result) => {
if (err) {
reject(this.convertPlayAPIErrorToLibraryError(err));
} else {
resolve(result.data);
}
})
});
LOGS Firebase Functions
6:55:28.798 PM instanceId_register_v2 Function execution started
6:55:31.025 PM instanceId_register_v2 Instance id is ddR1Hi...NOO2Z
6:55:31.122 PM instanceId_register_v2 Instance Id specified and verified
6:55:31.122 PM instanceId_register_v2 Instance verification passed
6:55:31.774 PM instanceId_register_v2 Function execution took 2976 ms, finished with status code: 200
6:55:53.623 PM realtime_notification_listener ========> purchase: null PACKAGE_NAME: com.example.subscriptions
6:55:53.624 PM realtime_notification_listener Function execution took 5 ms, finished with status: 'ok'
6:55:57.537 PM subscription_register_v2 Function execution started
6:55:59.817 PM subscription_register_v2 Server error: Cannot read property 'get' of undefined
6:55:59.825 PM subscription_register_v2 Function execution took 2289 ms, finished with status code: 500
LOGS Android Studio
D/OkHttp: --> PUT https://us-central1-postosgnv.cloudfunctions.net/subscription_register_v2 http/1.1 (437-byte body)
D/OkHttp: <-- 500 https://us-central1-postosgnv.cloudfunctions.net/subscription_register_v2 (2661ms, 86-byte body)
E/RemoteServerFunction: Failed to call API (Error code: 500) - {"status":500,"error":"not-found","message":"Cannot read property 'get' of undefined"}
As per the answer found HERE, the issue was solved by updating the GoogleApis package in the package.json from "googleapis": "^67.0.0" -> "googleapis": "105.0.0"
I entegrated my flutter app with onesignal, and it's working perfect when app is in background, but in foreground it's receiving notification but not showing it any idea why?
log
flutter: OSNotificationReceivedEvent complete with notification: Instance of 'OSNotification'
VERBOSE: finishProcessingNotification: Fired!
VERBOSE: Notification display type: 7
VERBOSE: notificationReceived called! opened: NO
VERBOSE: finishProcessingNotification: call completionHandler with options: 7
Foreground handler
OneSignal.shared.setNotificationWillShowInForegroundHandler(
(OSNotificationReceivedEvent event) {
event.complete(event.notification);
});
I've removed the answer because I think it is just copy paste
I have a problem with WebSocket being disconnected while trying to firstly save entity to the database with EF Core, then to dispatch a message to the clients using SignalR Core.
Everything works perfectly when I separate these two operations, one with AJAX call to the controller's action, to save entity to the database, one with hub method for dispatching messages to the clients. But I want to ensure that the entity is successfully saved, then to be dispatched.
When I try to merge saving entity and dispatching a message to the clients into the same hub method or controller's action (with dependency injection), I've got the errors which could be found down bellow (with log level - trace).
00:51:03.876 [2020-01-04T23:51:03.877Z] Trace: (WebSockets transport) sending data. String data of length 307. Utils.ts:178:39
00:51:04.147 [2020-01-04T23:51:04.148Z] Trace: (WebSockets transport) socket closed. Utils.ts:178:39
00:51:04.148 [2020-01-04T23:51:04.148Z] Debug: HttpConnection.stopConnection(undefined) called while in state Connected. Utils.ts:178:39
00:51:04.148 [2020-01-04T23:51:04.149Z] Information: Connection disconnected. Utils.ts:174:39
00:51:04.149 [2020-01-04T23:51:04.149Z] Debug: HubConnection.connectionClosed(undefined) called while in state Connected. Utils.ts:178:39
00:51:04.149 [2020-01-04T23:51:04.149Z] Information: Connection reconnecting. Utils.ts:174:39
00:51:04.150 [2020-01-04T23:51:04.150Z] Information: Reconnect attempt number 1 will start in 0 ms. Utils.ts:174:39
00:51:04.150 Chat - Error: Invocation canceled due to the underlying connection being closed. conversation line 2 > scriptElement:27:36
00:51:04.153 [2020-01-04T23:51:04.153Z] Debug: Starting connection with transfer format 'Text'. Utils.ts:178:39
00:51:04.154 [2020-01-04T23:51:04.154Z] Debug: Sending negotiation request: http://localhost:11597/chatHub/negotiate?negotiateVersion=1. Utils.ts:178:39
00:51:04.168 [2020-01-04T23:51:04.169Z] Debug: Selecting transport 'WebSockets'. Utils.ts:178:39
00:51:04.168 [2020-01-04T23:51:04.169Z] Trace: (WebSockets transport) Connecting. Utils.ts:178:39
00:51:04.179 [2020-01-04T23:51:04.180Z] Information: WebSocket connected to ws://localhost:11597/chatHub?id=Amf9CsFZQfnR8-3PoGr8HQ. Utils.ts:174:39
00:51:04.179 [2020-01-04T23:51:04.180Z] Debug: The HttpConnection connected successfully. Utils.ts:178:39
00:51:04.180 [2020-01-04T23:51:04.180Z] Debug: Sending handshake request. Utils.ts:178:39
00:51:04.180 [2020-01-04T23:51:04.181Z] Debug: Hub handshake failed with error 'WebSocket is not in the OPEN state' during start(). Stopping HubConnection. Utils.ts:178:39
00:51:04.181 [2020-01-04T23:51:04.181Z] Trace: (WebSockets transport) socket closed. Utils.ts:178:39
00:51:04.181 [2020-01-04T23:51:04.182Z] Debug: HttpConnection.stopConnection(undefined) called while in state Disconnecting. Utils.ts:178:39
00:51:04.182 [2020-01-04T23:51:04.182Z] Error: Connection disconnected with error 'WebSocket is not in the OPEN state'. Utils.ts:168:39
00:51:04.183 [2020-01-04T23:51:04.184Z] Debug: HubConnection.connectionClosed(WebSocket is not in the OPEN state) called while in state Reconnecting. Utils.ts:178:39
00:51:04.183 [2020-01-04T23:51:04.184Z] Information: Reconnect attempt failed because of error 'WebSocket is not in the OPEN state'. Utils.ts:174:39
00:51:04.184 [2020-01-04T23:51:04.185Z] Information: Reconnect attempt number 2 will start in 2000 ms. Utils.ts:174:39
Here is hub method:
public async Task SendMessage(Message message)
{
// Eager loading conversation with matching Id
var chat = _context.Chat
.Include(c => c.PersonA)
.Include(c => c.PersonB)
.FirstOrDefault(m => m.Id == message.ChatId);
/*
* I'm doing a few validations here
*/
// Saving entity to the database
await _context.AddAsync(new Message
{
SenderId = message.SenderId,
ChatId = message.ChatId,
Text = message.Text
});
await _context.SaveChangesAsync();
// Dispatching message to the clients using strongly-typed hub
var usersId = new List<string> { chat.PersonAId, chat.PersonBId };
await Clients
.Users(usersId)
.ReceiveMessage(message);
}
The potential problem could lie in timing, the dispatching can't wait for the EF to execute all operations, because when I just load the conversation It works good, adding more complexity, it breaks down.
I have worked app with Push on Dev server. When I deploy my project on Production environment and trigger Push send event from app, I get error
"An error was encountered while processing the request from the application.".
Please, help me to resolve this problem.
PushAdapter.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wl:adapter xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PushAdapter">
<displayName>PushAdapter</displayName>
<description>PushAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>cnn.com</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2"/>
</connectivity>
<procedure name="submitNotification" securityTest="wl_unprotected"/>
</wl:adapter>
PushAdapter-impl.js
WL.Server.createEventSource({
name: 'PushEventSource',
onDeviceSubscribe: 'deviceSubscribeFunc',
onDeviceUnsubscribe: 'deviceUnsubscribeFunc',
securityTest: 'AngularStarter-strong-mobile-securityTest'
});
function deviceSubscribeFunc(userSubscription, deviceSubscription){
WL.Logger.debug(">> deviceSubscribeFunc");
WL.Logger.debug(userSubscription);
WL.Logger.debug(deviceSubscription);
}
function deviceUnsubscribeFunc(userSubscription, deviceSubscription){
WL.Logger.debug(">> deviceUnsubscribeFunc");
WL.Logger.debug(userSubscription);
WL.Logger.debug(deviceSubscription);
}
function submitNotification(userId, notificationText) {
var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId);
if (userSubscription == null) {
return { result: "No subscription found for user :: " + userId };
}
var badgeDigit = 1,
notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom: "data"});
WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText);
WL.Server.notifyAllDevices(userSubscription, notification);
return {
result: "Notification sent to user :: " + userId
};
}
LogCat info
10-18 20:52:41.550: D/NONE(1819): Request [http://server/context/apps/services/../../invoke]
10-18 20:52:41.601: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/invoke
10-18 20:52:41.661: D/dalvikvm(1819): GC_FOR_ALLOC freed 674K, 27% free 10121K/13800K, paused 18ms, total 18ms
10-18 20:52:41.711: D/NONE(1819): Request [http://server/context/apps/services/api/ProjectName/android/notifications]
10-18 20:52:41.751: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/apps/services/api/ProjectName/android/notifications
10-18 20:52:41.771: D/push(1819): Push.dispatch in Push.java:350 :: Push.dispatch(): method=WL.Client.Push.__onmessage
10-18 20:52:41.771: D/push(1819): Push.dispatch in Push.java:359 :: Javascript script requests dispatching to WL.Client.Push.__onmessage
10-18 20:52:41.791: D/dalvikvm(1819): GC_FOR_ALLOC freed 510K, 27% free 10116K/13800K, paused 18ms, total 18ms
10-18 20:52:41.801: D/NONE(1819): Request [http://server/context/apps/services/api/ProjectName/android/login]
10-18 20:52:41.831: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/apps/services/api/ProjectName/android/login
10-18 20:52:41.851: D/NONE(1819): Request [http://server/context/apps/services/api/ProjectName/android/query]
10-18 20:52:41.881: D/dalvikvm(1819): GC_FOR_ALLOC freed 496K, 27% free 10130K/13800K, paused 18ms, total 18ms
10-18 20:52:41.901: D/NONE(1819): Clearing notification subscriptions.
10-18 20:52:41.921: D/dalvikvm(1819): GC_FOR_ALLOC freed 162K, 25% free 10474K/13800K, paused 19ms, total 19ms
10-18 20:52:41.921: D/GCMRegistrar(1819): resetting backoff for com.ProjectName
10-18 20:52:41.921: V/GCMRegistrar(1819): Registering app com.ProjectName of senders 1010830861176
10-18 20:52:41.921: D/NONE(1819): Clearing tag notification subscriptions.
10-18 20:52:41.931: D/NONE(1819): Send new server notification token id.
10-18 20:52:41.931: D/NONE(1819): Updating tag notification subscriptions.
10-18 20:52:41.941: D/NONE(1819): response [http://server/context/apps/services/api/ProjectName/android/login] success: /*-secure-
10-18 20:52:41.941: D/NONE(1819): {"wl_directUpdateRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null"},"wl_authenticityRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"AdapterAuthRealm":{"userId":"demo","isUserAuthenticated":1,"displayName":"demo"},"WL-Authentication-Success":{"AdapterAuthRealm":{"userId":"demo","isUserAuthenticated":1,"displayName":"demo"}},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null"},"notificationSubscriptionState":{"tags":["Push.ALL"],"eventSources":[],"token":"APA91bFNbZIblAxjd1ls6ldN_LbwU77-nM3R9LtP7cxAXcU1q4WCM1tthy6p6v7YLWmHqDwC3nNg4TNDkCm9ZVOtJCQGIRySBMf1gWq3nUdLFmX9BSIItxas5l7cYcGMvycPF1cxt58M_s29XxVY9uD7FbDM3IJNGA"},"wl_antiXSRFRealm":{"userId":"nbtk4iv001kpt5rvl5dra6q07v","attributes":{},"isUserAuthenticated":1,"displayName":"nbtk4iv001kpt5rvl5dra6q07v"},"wl_deviceAutoProvisioningRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"wl_deviceNoProvisioningRealm":{"userId":"52318dd3-900b-3a85-8752-fbf53cfec056","attributes":{"mobileClientData":"com.worklight.core.auth.ext.MobileClientData#2a92dd52"},"isUserAuthenticated":1,"displayName":"52318dd3-900b-3a85-8752-fbf53cfec056"},"myserver":{"userId":"a20252a0-954f-46ae-bb55-2984c8fae7b6","attributes":{},"isUserAuthenticated":1,"displayName":"a20252a0-954f-46ae-bb55-2984c8fae7b6"},"wl_anonymousUserRealm":{"userId":"a20252a0-954f-46ae-bb55-2984c8fae7b6","attributes":{},"isUserAuthenticated":1,"displayName":"a20252a0-954f-46ae-bb55-2984c8fae7b6"}}*/
10-18 20:52:41.941: D/NONE(1819): defaultOptions:onSuccess
10-18 20:52:41.981: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/apps/services/api/ProjectName/android/query
10-18 20:52:42.031: D/dalvikvm(1819): GC_FOR_ALLOC freed 401K, 24% free 10584K/13800K, paused 18ms, total 19ms
10-18 20:52:42.171: V/GCMBroadcastReceiver(1819): onReceive: com.google.android.c2dm.intent.REGISTRATION
10-18 20:52:42.171: V/GCMBroadcastReceiver(1819): GCM IntentService class: com.ProjectName.GCMIntentService
10-18 20:52:42.171: V/GCMBaseIntentService(1819): Acquiring wakelock
10-18 20:52:42.181: V/GCMBaseIntentService(1819): Intent service name: GCMIntentService-DynamicSenderIds-2
10-18 20:52:42.181: D/GCMBaseIntentService(1819): handleRegistration: registrationId = APA91bFNbZIblAxjd1ls6ldN_LbwU77-nM3R9LtP7cxAXcU1q4WCM1tthy6p6v7YLWmHqDwC3nNg4TNDkCm9ZVOtJCQGIRySBMf1gWq3nUdLFmX9BSIItxas5l7cYcGMvycPF1cxt58M_s29XxVY9uD7FbDM3IJNGA, error = null, unregistered = null
10-18 20:52:42.181: D/GCMRegistrar(1819): resetting backoff for com.ProjectName
10-18 20:52:42.181: V/GCMRegistrar(1819): Saving regId on app version 20
10-18 20:52:42.191: D/GCMIntentService(1819): GCMIntentService.onRegistered in GCMIntentService.java:75 :: WLGCMIntentService: Registered at the GCM server with registration id APA91bFNbZIblAxjd1ls6ldN_LbwU77-nM3R9LtP7cxAXcU1q4WCM1tthy6p6v7YLWmHqDwC3nNg4TNDkCm9ZVOtJCQGIRySBMf1gWq3nUdLFmX9BSIItxas5l7cYcGMvycPF1cxt58M_s29XxVY9uD7FbDM3IJNGA
10-18 20:52:42.191: V/GCMBaseIntentService(1819): Releasing wakelock
10-18 20:52:42.251: D/CordovaWebViewClient(1819): onPageFinished(file:///android_asset/www/default/index.html#/inbox/index)
10-18 20:52:42.251: D/CordovaActivity(1819): onMessage(onPageFinished,file:///android_asset/www/default/index.html#/inbox/index)
10-18 20:52:42.321: D/NONE(1819): response [http://server/context/apps/services/api/ProjectName/android/query] success: /*-secure-
10-18 20:52:42.321: D/NONE(1819): {"isSuccessful":true,"result":"No subscription found for user :: null"}*/
10-18 20:52:42.321: W/NONE(1819): Event source callback is already registered with alias: myPush
10-18 20:52:44.323: D/NONE(1819): Piggybacking event transmission
10-18 20:52:44.333: D/NONE(1819): Flush called
Server Logs
https://www.dropbox.com/s/2j0efjcxmbw0mfg/52318dd3-900b-3a85-8752-fbf53cfec056-logs-3.json?dl=0
In the PushAdapter-impl.js/submitNotification, you send a notification to a subscribed user whose userId is passed in as the parameter to adapter (userId).
Inspecting the logcat logs - the subscription for that user doesn't exist in Worklight - you might have never called WL.Client.subscribe() from the app.
I am trying to use Worklight push notification to send push for a iOS+Android Application.
I created the submitNotification function in my adapter, and when I invoke it, it says that the push was sent successfully, but in reality, I have no push received in my device.
When I see the logs I can read:
Couldn't connect to APNS server
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
java.net.Socket.connect(Socket.java:529)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:371)
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:133)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)
and
Couldn't send message com.notnoop.apns.EnhancedApnsNotification#96eee2c0 com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:146)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)
then
Failed to send message com.notnoop.apns.EnhancedApnsNotification#96eee2c0... trying again
My submitNotification function :
function submitNotification(userId, notificationText) {
var userSubscription = WL.Server.getUserNotificationSubscription(
'myAdapter.MyPushEventSource', userId);
if (userSubscription == null) {
return {
result : "No subscription found for user :: " + userId
};
}
WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: "
+ notificationText);
WL.Server.notifyAllDevices(userSubscription, {
badge : 1,
activateButtonLabel : "Open",
alert : notificationText
});
return {
result : "Notification sent to user :: " + userId
};
}
Is there something wrong with my code? or with my Network ?
It was finally a network issue.
We changed our Firewall configuration to allow access to Google and Apple push servers.
For Apple Servers, you can find more details at this address : http://developer.apple.com/library/ios/#technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG41
the entire 17.0.0.0/8 address block is assigned to Apple, so you can
specify that range in your firewall rules.